I need help with a move definition Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » I need help with a move definition « Previous Next »

Author Message
Keith Carter (Keithc)
Posted on Sunday, December 10, 2000 - 2:01 am:   

The goal

I am working on a chess variant. As part of it I want to have a pawn advance one rank, while switching places with a friendly piece, and promote the pawn if the pawn has moved into a promotion zone.

For example there is a white pawn on a7 and a white knight on a8. The pawn would move to a8, the knight would be swapped to a7, and the pawn would promote.


The problem

Promoting the pawn before swapping terminates the move definition upon the promotion and no swap occurs. The piece moved upon is captured. The knight on a8 in the example.

Swapping the pieces before the promotion leaves the focus of the move on the starting square (a7 in the example). Changing the focus back to the pawn (a8 in the example) creates the following game rules error:

A move was generated from a7 to a8 when there was no piece on a7. The game will probably not work as expected. Should I continue reporting these errors?


Example code

The following code works but produces the game rules error. Tell Zillions not to continue reporting the error and the game works as expected.

(define Pawn-swap (
mark
$1
(verify friend?)
cascade
back
cascade
$1
(if (in-zone? promotion-zone) (add Knight Bishop Rook Queen) )
add
) )


Clues to the mystery

The error code is produced twice by the move definition. It is probably related to the two cascade commands.

Removing the second $1 causes the piece that is swapped to promote. The knight that ends up on a7 in the example.

The example uses mark and back but using from and to produces the same error.

There might be a solution in reversing the order of the swap and then promoting. Using the example there may be some way to move the knight on a8 to a7, the pawn on a7 to a8, and then promote the pawn. I have tried using from and to without success.

Keith Carter
Dan Troyka (Dtroyka)
Posted on Sunday, December 10, 2000 - 9:45 am:   

The following code should work:

(define Pawn-swap
(
$1
(verify friend?)
cascade back to $1 cascade
(if (in-zone? promotion-zone)
(add-partial Knight Bishop Rook Queen) else add)
)
)

For what it's worth, the exact code that did work, when substituted for the Pawn-move macro in the Chess rules file, was:

(define Pawn-move
(
n
(verify friend?)
cascade back to n cascade
(if (in-zone? promotion-zone)
(add-partial Knight Bishop Rook Queen) else add)
)
)
Dan Troyka (Dtroyka)
Posted on Sunday, December 10, 2000 - 9:52 am:   

P.S. That should be "add" and not "add-partial" before "Knight Bishop Rook Queen".
Dan Troyka (Dtroyka)
Posted on Sunday, December 10, 2000 - 9:53 am:   

P.S. That should be "add" and not "add-partial" before "Knight Bishop Rook Queen".

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: