; *** Swap Chess ; *** Copyright 1999 - Joao Pedro Neto (game conception and zrf programming) ; portions Copyright 1998-9 Zillions Development Corporation (define leap1 ($1 (verify not-friend?) add) ) (define swap1 ( (set-flag canPromote (in-zone? promotion-zone) ) (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 (verify not-empty?) (verify (or (or (not-piece? Pawn) enemy?) (not-flag? canPromote) )) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) add ) ) (define Pawn-swap ( (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 (verify not-empty?) (verify (not-in-zone? promotion-zone) ) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) add ) ) (define Pawn-swap2 ( ; for double move on 1st and 2nd row (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 (verify (in-zone? third-rank)) (verify empty?) $1 (verify not-empty?) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) (opposite $1) add ) ) (define leap2 ($1 $2 (verify not-friend?) add) ) (define swap2 ( (set-flag canPromote (in-zone? promotion-zone) ) (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 $2 (verify not-empty?) (verify (or (or (not-piece? Pawn) enemy?) (not-flag? canPromote) )) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) (opposite $2) add ) ) (define slide ($1 (while empty? add $1) (verify not-friend?) add)) (define swapSlide ( (set-flag canPromote (in-zone? promotion-zone) ) (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) mark $1 (while empty? $1) (verify (or (or (not-piece? Pawn) enemy?) (not-flag? canPromote) )) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade back add ) ) (define Pawn-add (if (in-zone? promotion-zone) (add Knight Bishop Rook Queen) else add) ) (define Pawn-move ( n (verify empty?) (Pawn-add) (verify (in-zone? third-rank)) n (verify empty?) add ) ) (define Pawn-capture ( $1 (verify enemy?) (Pawn-add) ) ) (define Board-Definitions (image "images\Chess\Chess8x8.bmp") (grid (start-rectangle 5 5 55 55) (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 enemy-promotion-zone) (players White) (positions a1 b1 c1 d1 e1 f1 g1 h1) ) (zone (name enemy-promotion-zone) (players Black) (positions a8 b8 c8 d8 e8 f8 g8 h8) ) (zone (name third-rank) ; Pawns can stay in the 1st (8th) column (players White) (positions a3 b3 c3 d3 e3 f3 g3 h3 a2 b2 c2 d2 e2 f2 g2 h2) ) (zone (name third-rank) (players Black) (positions a6 b6 c6 d6 e6 f6 g6 h6 a7 b7 c7 d7 e7 f7 g7 h7) ) ) (game (title "Swap Chess") (description "Object: Capture the opponentīs King. Each piece can move like FIDE chess and also swap with a piece in a square where it can move (if it was empty) or take (if it had an enemy). There is no castling and en-passant rules. You cannot make a Swap if it implies a promotion. To see a description of how a piece moves right-click on it to bring up its properties dialog.\\.") (history "Several variants of these idea, the swap of 2 pieces, where invented by Joao Pedro Neto in 1998 (www.di.fc.ul.pt/~jpn/cv/CVindex.htm)") (strategy "Try to advance your Pawns with swappings.\\ Remember that a well defended piece may become in danger with a single swap.\\ Pawns are more powerful, since they have 3 more moves (swapping with any forward piece).") (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) (pass-turn false) (board (Board-Definitions)) (board-setup (White (Pawn a2 b2 c2 d2 e2 f2 g2 h2) (Knight b1 g1) (Bishop c1 f1) (Rook a1 h1) (Queen d1) (King e1) ) (Black (Pawn a7 b7 c7 d7 e7 f7 g7 h7) (Knight b8 g8) (Bishop c8 f8) (Rook a8 h8) (Queen d8) (King e8) ) ) (piece (name Pawn) (help "Pawn: moves forward, captures diagonally, can promote on 8th row") (description "Pawn\A Pawn can move straight ahead one square, or two squares from its starting position. A Pawn captures by moving one square ahead and diagonally. If a Pawn reaches the far rank it promotes, changing into a Knight, Bishop, Rook, or Queen.") (image White "images\Chess\wpawn.bmp" Black "images\Chess\bpawn.bmp") (moves (move-type slide-move) (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) (move-type swap-move) (Pawn-swap ne) (Pawn-swap nw) (Pawn-swap n) (Pawn-swap2 n) ) ) (piece (name Knight) (help "Knight: moves like an `L`, 2 squares one way and one the other") (description "Knight\A Knight moves like an `L`, two squares vertically plus one horizontally, or two squares horizontally plus one vertically. It hops over any pieces on the way.") (image White "images\Chess\wknight.bmp" Black "images\Chess\bknight.bmp") (moves (move-type slide-move) (leap2 n ne) (leap2 n nw) (leap2 s se) (leap2 s sw) (leap2 e ne) (leap2 e se) (leap2 w nw) (leap2 w sw) (move-type swap-move) (swap2 n ne) (swap2 n nw) (swap2 s se) (swap2 s sw) (swap2 e ne) (swap2 e se) (swap2 w nw) (swap2 w sw) ) ) (piece (name Bishop) (help "Bishop: slides diagonally any number of squares") (description "Bishop\A Bishop moves any number of squares on a diagonal. It may not leap over other pieces.") (image White "images\Chess\wbishop.bmp" Black "images\Chess\bbishop.bmp") (moves (move-type slide-move) (slide ne) (slide nw) (slide se) (slide sw) (move-type swap-move) (swapSlide ne) (swapSlide nw) (swapSlide se) (swapSlide sw) ) ) (piece (name Rook) (help "Rook: slides any number of squares along the row or column.") (description "Rook\A Rook moves any number of squares orthogonally on a rank or a file. It may not leap over other pieces.") (image White "images\Chess\wrook.bmp" Black "images\Chess\brook.bmp") (attribute never-moved? true) (moves (move-type slide-move) (slide n) (slide e) (slide s) (slide w) (move-type swap-move) (swapSlide n) (swapSlide e) (swapSlide s) (swapSlide w) ) ) (piece (name Queen) (help "Queen: can slide any number of squares in any direction") (description "Queen\A Queen moves any number of squares in a straight line. It may not leap over other pieces.") (image White "images\Chess\wqueen.bmp" Black "images\Chess\bqueen.bmp") (moves (move-type slide-move) (slide n) (slide e) (slide s) (slide w) (slide ne) (slide nw) (slide se) (slide sw) (move-type swap-move) (swapSlide n) (swapSlide e) (swapSlide s) (swapSlide w) (swapSlide ne) (swapSlide nw) (swapSlide se) (swapSlide sw) ) ) (piece (name King) (help "King: steps 1 square in any direction to a safe square") (description "King\A King can move to any adjacent square, but remember if itīs captured, you loose!") (image White "images\Chess\wking.bmp" Black "images\Chess\bking.bmp") (moves (move-type slide-move) (leap1 n) (leap1 e) (leap1 s) (leap1 w) (leap1 ne) (leap1 nw) (leap1 se) (leap1 sw) (move-type swap-move) (swap1 n) (swap1 e) (swap1 s) (swap1 w) (swap1 ne) (swap1 nw) (swap1 se) (swap1 sw) ) ) (loss-condition (White Black) (pieces-remaining 0 King) ) ) ; ************************************************************************** ; VARIANTS ; ************************************************************************** (variant (title "-") ; -------------------------------------------------------- ) (variant (title "Balanced Swap Chess") (description "Itīs the same as in Swap Chess, but each player takes 2 moves for turn, one normal move and one swap move. The 1st white move has just the normal move.\\A stalemate player, looses!\\ This is my favorite Swap Chess Variant!") (default) (turn-order (White slide-move) repeat (Black slide-move) (Black swap-move) (White slide-move) (White swap-move) ) (loss-condition (White Black) (pieces-remaining 0 King) ) (loss-condition (White Black) stalemated ) ) ; variant Balanced Swap Chess (variant (title "Swap Chess with normal Pawns") (description "Itīs the same as in Swap Chess, but Pawns cannot swap!") (piece (name Pawn) (help "Pawn: moves forward, captures diagonally, can promote on 8th row") (description "Pawn\A Pawn can move straight ahead one square, or two squares from its starting position. A Pawn captures by moving one square ahead and diagonally. If a Pawn reaches the far rank it promotes, changing into a Knight, Bishop, Rook, or Queen.") (image White "images\Chess\wpawn.bmp" Black "images\Chess\bpawn.bmp") (moves (move-type slide-move) (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) ) ) ) ; variant Swap Chess with normal Pawns ; ************************************************************************** ; VARIANTS WITH MULTIPLE SWAPS ; ************************************************************************** (variant (title "-") ; -------------------------------------------------------- ) (define CRswap1 ( (set-flag canPromote (in-zone? promotion-zone) ) (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 (verify not-empty?) (verify (or (or (not-piece? Pawn) enemy?) (not-flag? canPromote) )) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) (add-partial swap-move) ) ) (define Pawn-CRswap ( (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 (verify not-empty?) (verify (not-in-zone? promotion-zone) ) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) (add-partial swap-move) ) ) (define Pawn-CRswap2 ( ; for double move on 1st and 2nd row (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 (verify (in-zone? third-rank)) (verify empty?) $1 (verify not-empty?) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) (opposite $1) (add-partial swap-move) ) ) (define CRswap2 ( (set-flag canPromote (in-zone? promotion-zone) ) (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) $1 $2 (verify not-empty?) (verify (or (or (not-piece? Pawn) enemy?) (not-flag? canPromote) )) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade (opposite $1) (opposite $2) (add-partial swap-move) ) ) (define CRswapSlide ( (set-flag canPromote (in-zone? promotion-zone) ) (set-flag canEnemyPromote (in-zone? enemy-promotion-zone) ) mark $1 (while empty? $1) (verify (or (or (not-piece? Pawn) enemy?) (not-flag? canPromote) )) (verify (or (or (not-piece? Pawn) friend?) (not-flag? canEnemyPromote) )) cascade back (add-partial swap-move) ) ) (variant (title "Swap Chess with Swapper") (description "Itīs the same as in Swap Chess, but you have a special piece, the swapper, that is like the queen, but itīs able to swap as many pieces as you like in one move.") (strategy "The strategy is similar to Swap Chess, but here you may have the possibility of change ay army, if you use wisely your Swapper.\\ And donīt forget, you just have one! If you loose it...") (pass-partial true) (board-setup (White (Pawn a2 b2 c2 d2 e2 f2 g2 h2) (Knight b1 g1) (Bishop c1 f1) (Rook a1 h1) (Swapper d1) (King e1) ) (Black (Pawn a7 b7 c7 d7 e7 f7 g7 h7) (Knight b8 g8) (Bishop c8 f8) (Rook a8 h8) (Swapper d8) (King e8) ) ) (piece (name Swapper) (help "Swapper: like queen and also swap as many pieces as you like.") (description "Swapper\A Queen moves any number of squares in a straight line. It may not leap over other pieces. Swap with any number of pieces. You cannot promote a Pawn into a Swapper.") (image White "images\Chess\wdownqueen.bmp" Black "images\Chess\bdownqueen.bmp") (moves (move-type slide-move) (slide n) (slide e) (slide s) (slide w) (slide ne) (slide nw) (slide se) (slide sw) (move-type swap-move) (CRswapSlide n) (CRswapSlide e) (CRswapSlide s) (CRswapSlide w) (CRswapSlide ne) (CRswapSlide nw) (CRswapSlide se) (CRswapSlide sw) ) ) ) ; variant Swap Chess with Swapper (variant (title "Chain Reaction Swap Chess") (description "Now everyone is a swapper. Chaos!!!") (strategy "There is no strategy! :-) Run for your lifes!!!") (pass-partial true) (piece (name Pawn) (help "Pawn: moves forward, captures diagonally, can promote on 8th row") (description "Pawn\A Pawn can move straight ahead one square, or two squares from its starting position. A Pawn captures by moving one square ahead and diagonally. If a Pawn reaches the far rank it promotes, changing into a Knight, Bishop, Rook, or Queen.") (image White "images\Chess\wpawn.bmp" Black "images\Chess\bpawn.bmp") (moves (move-type slide-move) (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) (move-type swap-move) (Pawn-CRswap ne) (Pawn-CRswap nw) (Pawn-CRswap n) (Pawn-CRswap2 n) ) ) (piece (name Knight) (help "Knight: moves like an `L`, 2 squares one way and one the other") (description "Knight\A Knight moves like an `L`, two squares vertically plus one horizontally, or two squares horizontally plus one vertically. It hops over any pieces on the way.") (image White "images\Chess\wknight.bmp" Black "images\Chess\bknight.bmp") (moves (move-type slide-move) (leap2 n ne) (leap2 n nw) (leap2 s se) (leap2 s sw) (leap2 e ne) (leap2 e se) (leap2 w nw) (leap2 w sw) (move-type swap-move) (CRswap2 n ne) (CRswap2 n nw) (CRswap2 s se) (CRswap2 s sw) (CRswap2 e ne) (CRswap2 e se) (CRswap2 w nw) (CRswap2 w sw) ) ) (piece (name Bishop) (help "Bishop: slides diagonally any number of squares") (description "Bishop\A Bishop moves any number of squares on a diagonal. It may not leap over other pieces.") (image White "images\Chess\wbishop.bmp" Black "images\Chess\bbishop.bmp") (moves (move-type slide-move) (slide ne) (slide nw) (slide se) (slide sw) (move-type swap-move) (CRswapSlide ne) (CRswapSlide nw) (CRswapSlide se) (CRswapSlide sw) ) ) (piece (name Rook) (help "Rook: slides any number of squares along the row or column.") (description "Rook\A Rook moves any number of squares orthogonally on a rank or a file. It may not leap over other pieces.") (image White "images\Chess\wrook.bmp" Black "images\Chess\brook.bmp") (attribute never-moved? true) (moves (move-type slide-move) (slide n) (slide e) (slide s) (slide w) (move-type swap-move) (CRswapSlide n) (CRswapSlide e) (CRswapSlide s) (CRswapSlide w) ) ) (piece (name Queen) (help "Queen: like queen and also swap as many pieces as you like.") (description "Queen\A Queen moves any number of squares in a straight line. It may not leap over other pieces.") (image White "images\Chess\wqueen.bmp" Black "images\Chess\bqueen.bmp") (moves (move-type slide-move) (slide n) (slide e) (slide s) (slide w) (slide ne) (slide nw) (slide se) (slide sw) (move-type swap-move) (CRswapSlide n) (CRswapSlide e) (CRswapSlide s) (CRswapSlide w) (CRswapSlide ne) (CRswapSlide nw) (CRswapSlide se) (CRswapSlide sw) ) ) (piece (name King) (help "King: steps 1 square in any direction to a safe square") (description "King\A King can move to any adjacent square, but remember if itīs captured, you loose!") (image White "images\Chess\wking.bmp" Black "images\Chess\bking.bmp") (moves (move-type slide-move) (leap1 n) (leap1 e) (leap1 s) (leap1 w) (leap1 ne) (leap1 nw) (leap1 se) (leap1 sw) (move-type swap-move) (CRswap1 n) (CRswap1 e) (CRswap1 s) (CRswap1 w) (CRswap1 ne) (CRswap1 nw) (CRswap1 se) (CRswap1 sw) ) ) ) ; Chain Reaction Swap Chess