Setting a flag if the piece moves? Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Setting a flag if the piece moves? « Previous Next »

Author Message
Tyler N. Jones (Cruentidei)
Posted on Sunday, August 15, 2004 - 3:23 pm:   

I'm trying to define a move that can only be done once. Once any piece makes that move, no other piece, including that one, can do it for the rest of the game. Right now, I've got

(define white-bishop-hop
(
$1
(if (not-flag? white-hop-flag?) (verify not-friend?) add)
)
)

This will allow the move if the flag is FALSE, and there is no friendly piece at $1, but I need to know where to set it to true. Anywhere I place the command

(set-flag white-hop-flag true)

in the move either wrecks the move or does nothing. I can't use the not moved attribute, since that would allow each piece to move once. Where am I supposed to place this in the move?
Sean Duggan (Dream)
Posted on Sunday, August 15, 2004 - 5:35 pm:   

Probably a more friendly way to do this, but I can do it with dummy pieces:

(define bishop-hop
(
$1
(if (in-zone? promotion-zone a8)
(verify (piece? CanHop whiteDummy))
else
(verify (piece? CanHop blackDummy))
)
(verify not-friend?) (capture whiteDummy) add
)
)

and define board and piece dummies:
(board (Board-Definitions) (dummy whiteDummy blackDummy))
&
(piece
(name CanHop)
(dummy)
)
Tyler N. Jones (Cruentidei)
Posted on Monday, August 16, 2004 - 2:04 pm:   

Thanks for the code, but it doesn't seem to work or even allow the move.

Maybe I can phrase it more basically.

How can I define a move such that the move is only allowed if a flag is currently FALSE, and then set that flag to TRUE once the move is made?
Sean Duggan (Dream)
Posted on Monday, August 16, 2004 - 7:50 pm:   

Trimmed to only the king and the bishop. Is this the effect you want? I don't understand flags well enough, I'm afraid.

(version "2.0")

(define king-shift-capture ($1 (verify enemy?) (set-attribute never-moved? false) add ) )
(define king-shift-move ($1 (verify empty?) (set-attribute never-moved? false) add) )
(define king-shift ($1 (verify not-friend?) (set-attribute never-moved? false) add) )
(define slide-capture ($1 (while empty? $1) (verify enemy?) add ) )
(define slide-move ($1 (while empty? add $1)) )


(define slide ($1 (while empty? add $1) (verify not-friend?) add))

(define bishop-hop
(
$1
(if (in-zone? promotion-zone a8)
(verify (piece? CanHop whiteDummy))
(verify not-friend?) (capture whiteDummy) add
else
(verify (piece? CanHop blackDummy))
(verify not-friend?) (capture blackDummy) add
)


)
)


(define Board-Definitions
(image "images\Chess\SHaag\Chess8x8.bmp" "images\Chess\Chess8x8.bmp")
(grid
(start-rectangle 5 5 53 53)
(dimensions
("a/b/c/d/e/f/g/h" (49 0)) ; files
("8/7/6/5/4/3/2/1" (0 49)) ; ranks
)
(directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
(ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
)
)
(symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne))
(zone
(name promotion-zone)
(players White)
(positions a8 b8 c8 d8 e8 f8 g8 h8)
)
(zone
(name promotion-zone)
(players Black)
(positions a1 b1 c1 d1 e1 f1 g1 h1)
)
(zone
(name third-rank)
(players White)
(positions a3 b3 c3 d3 e3 f3 g3 h3)
)
(zone
(name third-rank)
(players Black)
(positions a6 b6 c6 d6 e6 f6 g6 h6)
)
)

(game
(title "Chess")
(option "prevent flipping" 2)
(win-sound "Audio\Orchestra_CF.wav")
(loss-sound "Audio\Orchestra_FC.wav")
(click-sound "Audio\Pickup.wav")
(release-sound "Audio\WoodThunk.wav")
(players White Black)
(turn-order White Black)
(board (Board-Definitions) (dummy whiteDummy blackDummy))

(board-setup
(White
(Bishop c1 f1)
(King e1)
(CanHop whiteDummy)
)
(Black
(Bishop c8 f8)
(King e8)
(CanHop blackDummy)
)
)

(piece
(name CanHop)
(dummy)
)

(piece
(name Bishop)
(image White "images\Chess\SHaag\wbishop.bmp" "images\Chess\wbishop.bmp"
Black "images\Chess\SHaag\bbishop.bmp" "images\Chess\bbishop.bmp")
(moves
(move-type capture-move)
(slide-capture ne)
(slide-capture nw)
(slide-capture se)
(slide-capture sw)
(bishop-hop n)

(move-type non-capture-move)
(slide-move ne)
(slide-move nw)
(slide-move se)
(slide-move sw)
)
)

(piece
(name King)
(image White "images\Chess\SHaag\wking.bmp" "images\Chess\wking.bmp"
Black "images\Chess\SHaag\bking.bmp" "images\Chess\bking.bmp")
(attribute never-moved? true)
(moves
(king-shift n)
(king-shift e)
(king-shift s)
(king-shift w)
(king-shift ne)
(king-shift nw)
(king-shift se)
(king-shift sw)
)
)

(loss-condition (White Black) (checkmated King) )
)
Tyler N. Jones (Cruentidei)
Posted on Tuesday, August 17, 2004 - 12:12 pm:   

That did the trick! Thanks for the help and praise be to the dummy pieces!

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: