| Author |
Message |
Denis Kozlov (Denis)
| | Posted on Sunday, July 08, 2001 - 5:52 am: | |
How can I realize the following rule: pawn can move from file X to file Y only if player has more pawns in X than in Y? Some files have holes (some positions are killed). |
Dan Troyka (Dtroyka)
| | Posted on Sunday, July 08, 2001 - 5:06 pm: | |
This is in an interesting problem. You can solve it as follows. First, add the dead squares back onto the board by removing the kill-position statements. Then unlink these squares. If d4, for example, is a dead square, you can unlink it with: (unlink (c3 ne) (c4 e) (c5 se) (d3 n) (d5 s) (e3 nw) (e4 w) (e5 sw)) Now add four new directions that mimic the orthogonal directions: (n2 0 -1) (e2 1 0) (s2 0 1) (w2 -1 0) With this arrangement you can use the dead squares in your scans while removing them from play. You will need to redefine the Knight motion (if your game uses a Knight) using the new directions so that the Knight can jump over dead squares: (moves (leap2 n2 ne) . . . .) This requires adding "(n2 s2)(s2 n2)" to the symmetry statement. Now add the following macros: (define scan-file (while (and (or not-friend? (not-piece? Pawn)) (on-board? n2)) n2) (if (or not-friend? (not-piece? Pawn)) (verify false)) mark ) (define scan-adjacent-file (while (and (or not-friend? (not-piece? Pawn)) (on-board? n2)) n2) (if (or not-friend? (not-piece? Pawn)) (go from) $1 to add (verify false)) to ) (define B1 back (if (on-board? n) n else (verify false))) (define B2 (go to) (if (on-board? n) n else (go from) $1 to add (verify false))) (define Pawn-lateral ((verify (empty? $1)) (while (on-board? s2) s2) (scan-file) $1 (while (on-board? s2) s2) (scan-adjacent-file) (B1) (scan-file) (B2) (scan-adjacent-file) (B1) (scan-file) (B2) (scan-adjacent-file) (B1) (scan-file) (B2) (scan-adjacent-file) (B1) (scan-file) (B2) (scan-adjacent-file) (B1) (scan-file) (B2) (scan-adjacent-file) (B1) (scan-file) (B2) (scan-adjacent-file) (B1) (scan-file) (B2) (scan-adjacent-file) (B1) )) Finally, add the Pawn-lateral move to the Pawn's move block: (moves ... (Pawn-lateral e) (Pawn-lateral w) ... ) If you make these changes to the standard Zillions chess zrf, the result is that a Pawn can move to an empty square on either side (east or west) if there are more friendly Pawns in the current file than in the adjacent file. This works even in the extreme case of 8 Pawns in the current file and 7 in the adjacent file, and it works with dead squares (or at least with d4 a dead square as described above). Basically, what this code does is alternate scanning up the two files for the next friendly Pawn. At some point one of the files runs out of friendly Pawns. If the adjacent file runs out first, then there must be more friendly Pawns in the original file, and a lateral move is allowed into the adjacent file. If the original file runs out first, there must be more friendly Pawns in the adjacent file, and no lateral move is permitted into that file. This method avoids the necessity of counting all the Pawns, which can be tedious. |
Denis Kozlov (Denis)
| | Posted on Monday, July 09, 2001 - 1:29 pm: | |
Thanks, but it seems to be more tedious than counting pawns... |
Dan Troyka (Dtroyka)
| | Posted on Monday, July 09, 2001 - 3:17 pm: | |
The point is that you can't simply "count" Pawns in Zillions. Either you do something like what I described, or you don't do it at all. |
|