How to Replenish off-boards store? Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » How to Replenish off-boards store? « Previous Next »

Author Message
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 7
Registered: 5-2008
Posted on Saturday, December 29, 2012 - 4:23 am:   

I am working on a game where a player's captured pawns can be dropped back into play up to a maximum number of nine pawns on the board. Pawns that promote to Rook are not counted.
I have tried to use
(option "recycle captures" true)
The problem is that when a pawn promotes to Rook the total number of Pawns falls by one but there are no more pawns put into the off-board store to be dropped. This means that the maximum number of Pawns falls to eight rather than nine.

Another possibility is a shogi-style solution where captured pawns go to a side-table (without changing sides) and are moved rather than dropped back onto the play area. However I would like a solution that uses Zillions off-board store.

Is there any way to add a Pawn to the off-board store when a Pawn promotes to Rook?
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 8
Registered: 5-2008
Posted on Sunday, January 20, 2013 - 3:45 pm:   

I can think of two ways for another piece to test for check. Both use the "attacked?" function.

1) Search for the King, and then find out if it is "attacked?".
To search for the King, when defining the board create a link "next" linking all the squares on the board (see my recently posted game "Abagoren Chess" for an example, or any of numerous other games).
Create the macro "test-check" for movement of pieces which needs to know if the King is in check:
(define test-check
(mark next
(while not-marked?
(if (and friend? (piece? King))
(set-flag in-check attacked?))
next)))
After executng this function, the flag in-check can be tested as true or false.

2) Use a virtual King-move which only occurs when in check:
Define an off board position in the board definition (could be a dummy position, as no piece actually moves there eg (dummy END))
Include in the definition of King moves the move
(if attacked? (capture END) add)
Note that this move cannot actually be executed if the goal is checkmate, as it is a capture which cannot possibly get your king out of check. If the goal is not defined as checkmate, you may need to use move-type & move-priorities to stop an actual move being generated.
Then include in the move definition of the check-blocking move
(verify (defended? END))

Both the defended? and the attacked? functions are time-consuming for Zillions.

Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: