| Author |
Message |
Yu Ren Dong (Dandolo)
New member Username: Dandolo
Post Number: 6 Registered: 7-2008
| | Posted on Wednesday, June 24, 2009 - 10:56 pm: | |
I want to design a chess variant: When white player move a piece, his a2 pawn(if it still exists) would step a square automatically in the same time. For example. I could let a2 pawn move automatically when moving my King. (define King-shift ( $1 (verify not-friend?) cascade (if (and (friend? a2)(piece? pawn a2)) a2 from n) add) ) But, I don't know how to move a2 pawn simultaneously when I slide a queen or step other pawn to promote? Many thanks. |
M Winther (Kalroten)
New member Username: Kalroten
Post Number: 118 Registered: 1-2007
| | Posted on Thursday, June 25, 2009 - 12:30 am: | |
At promotion you could write (create Queen) cascade. But this means that pawns will always promote to Queen. Should the player want another piece then he can insert it manually (just as in real chess). When you slide a queen I suppose you must insert the cascade in the while loop. If this doesn't work, for some reason, then you can insert eight different moves into the moves clause in the Queen definition (and remove the standard queen-slide). The first move (queen-move1) moves the queen one step (like your king-shift). The queen-move2 is the same, except that $1 (verify empty?) is inserted first. Then the standard code $1 (verify not-friend?) cascade etc. is inserted. The queen-move3 begins with $1 (verify empty?) $1 (verify empty?) before the standard code, etc. /Mats |
Yu Ren Dong (Dandolo)
New member Username: Dandolo
Post Number: 7 Registered: 7-2008
| | Posted on Thursday, June 25, 2009 - 4:57 am: | |
Thank you very much. These all work! I thought a foolish method about the choose of promotion: (define Pawn-capture ( $1 (verify enemy?)(if (in-zone? promotion-zone) (create $2)) cascade (if (and (friend? a2)(piece? pawn a2)) a2 from n) add) ) (define Pawn-add ( $1 (verify empty?)(if (in-zone? promotion-zone) (create $2)) cascade (if (and (friend? a2)(piece? pawn a2)) a2 from n) add) ) (moves (Pawn-move n Queen) (Pawn-move n Rook) (Pawn-move n Bishop) (Pawn-move n Queen) (Pawn-capture ne Queen) (Pawn-capture nw Queen) (Pawn-capture ne Rook) (Pawn-capture nw Rook) (Pawn-capture ne Bishop) (Pawn-capture nw Bishop) (Pawn-capture ne Knight) (Pawn-capture nw Knight) ) |
Alfred Pfeiffer (Apf)
New member Username: Apf
Post Number: 16 Registered: 7-2000
| | Posted on Thursday, June 25, 2009 - 7:24 am: | |
How to embed an cascade action into a while cycle was a long time unclear. I wrote some about this in "/discus/messages/3/482.html". But it still remains difficult. The easiest way is not to use the cascade command but the capture and create commands, eg: (define slide-plus-move-a2 ( (while (empty? $1) ; while a free field ahead $1 ; we go the next step (if (and (friend? a2)(piece? pawn a2) (empty? a3)) (capture a2) (create pawn a3) ) add ) ; end while $1 (verify not-friend?) (if (and (friend? a2)(piece? pawn a2)(empty? a3)) (capture a2) (create pawn a3) ) add ) and also for promoting pawns use that method (define Pawn-capture $1 (verify enemy?) (if (and (friend? a2)(piece? pawn a2)(empty? a3)) (capture a2) (create pawn a3) ) (if (in-zone? promotion-zone) (add Queen Rook Knight Bishop) else add ) ) (define Pawn-add $1 (verify empty?) (if (and (friend? a2)(piece? pawn a2)(empty? a3)) (capture a2) (create pawn a3) ) (if (in-zone? promotion-zone) (add Queen Rook Knight Bishop) else add ) ) |
Yu Ren Dong (Dandolo)
New member Username: Dandolo
Post Number: 8 Registered: 7-2008
| | Posted on Friday, July 03, 2009 - 4:37 am: | |
Thank you. I've implementioned my varaint. http://www.chessvariants.org/index/msdisplay.php?itemid=MSchesswithdiffe |