; *** N-Relay Chess ; ZRF for Zillions-of-Games system, August 1999 ; implemented by Pierre Tourigny, ptourigny@videotron.ca (define Nrelay ( (if (or (and (piece? Knight nne) (friend? nne)) (and (piece? Knight nnw) (friend? nnw)) (and (piece? Knight sse) (friend? sse)) (and (piece? Knight ssw) (friend? ssw)) (and (piece? Knight ene) (friend? ene)) (and (piece? Knight ese) (friend? ese)) (and (piece? Knight wnw) (friend? wnw)) (and (piece? Knight wsw) (friend? wsw)) ) (if (on-board? nne) nne (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? nnw) nnw (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? sse) sse (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? ssw) ssw (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? ene) ene (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? wnw) wnw (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? ese) ese (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? wsw) wsw (if (and not-friend? (not-piece? Knight)) add)) ) )) (define Nprelay ( (if (or (and (piece? Knight nne) (friend? nne)) (and (piece? Knight nnw) (friend? nnw)) (and (piece? Knight sse) (friend? sse)) (and (piece? Knight ssw) (friend? ssw)) (and (piece? Knight ene) (friend? ene)) (and (piece? Knight ese) (friend? ese)) (and (piece? Knight wnw) (friend? wnw)) (and (piece? Knight wsw) (friend? wsw)) ) (if (on-board? nne) nne (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? nnw) nnw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? ene) ene (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? wnw) wnw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? sse) sse (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? ssw) ssw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? ese) ese (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? wsw) wsw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add)) ) )) (define Nleap ($1 (verify empty?) add) ) (define king-shift ($1 (verify (and not-friend? (not-piece? Knight))) (set-attribute never-moved? false) add) ) (define slide ($1 (while empty? add $1) (verify (and not-friend? (not-piece? Knight))) add)) (define rook-slide ( $1 (while empty? (set-attribute never-moved? false) add $1) (verify (and not-friend? (not-piece? Knight))) (set-attribute never-moved? false) add )) (define O-O ( (verify never-moved?) e ; KB1 (verify empty?) e ; KN1 (verify empty?) cascade e ; KR1 (verify (and friend? (piece? Rook) never-moved?) ) from back ; K1 ; Save expensive not-attacked?s for last (verify not-attacked?) e ; KB1 (verify not-attacked?) to (set-attribute never-moved? false) ; We could check if KN1 is attacked too, but this isn't ; really necessary since Zillions doesn't allow any moves ; into check e ; KN1 (set-attribute never-moved? false) add ) ) (define O-O-O ( (verify never-moved?) w ; Q1 (verify empty?) w ; QB1 (verify empty?) cascade w ; QN1 (verify empty?) w ; QR1 (verify (and friend? (piece? Rook) never-moved?) ) from back ; K1 ; Save expensive not-attacked?s for last (verify not-attacked?) w ; Q1 (verify not-attacked?) to (set-attribute never-moved? false) ; We could check if KN1 is attacked too, but this isn't ; really necessary since Zillions doesn't allow any moves ; into check w ; QB1 (set-attribute never-moved? false) 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 (and enemy? (not-piece? Knight))) (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) (nne 1 -2) (nnw -1 -2) (sse 1 2) (ssw -1 2) (ene 2 -1) (ese 2 1) (wnw -2 -1) (wsw -2 1) ) ) (symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne) (nne ssw) (ssw nne) (nnw sse) (sse nnw) (ene wsw) (wsw ene) (ese wnw) (wnw ese) ) (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) ) (zone (name nopawn) (players White Black) (positions a1 a8 b1 b8 c1 c8 d1 d8 e1 e8 f1 f8 g1 g8 h1 h8) ) ) (game (title "N-Relay Chess") (description "N-Relay\\ The rules of FIDE chess are in effect, with the exception of what follows. \\ 1. A piece other than a King is relayed the power to move and to capture as a Knight if it is defended by a Knight of the same color. This power adds to the usual power of the piece and lasts as long as the piece is guarded by a Knight. \\ 2. A pawn relayed by a Knight does not extend its powers to the first or eigth rank. For example, a White pawn on f6 guarded by a White Knight on e4 cannot move to e8 or g8. \\ 3. A pawn moved back to its second rank regains its right to a two-step move. \\ 4. Original or promoted Knights cannot be captured and do not capture even if they are defended by another Knight. \\ 5. There is no en passant capture.") (history "N-Relay Chess, sometimes also called Knight-Relay Chess was invented by Mannis Charosh around 1972. \\It was implemented for the Zillions-of-Games engine by Pierre Tourigny in August 1999.\\It is regularly played in modern chess variant circles.") (strategy "Knights make excellent shields because they cannot be catured.\\The relay makes pawns more mobile and dangerous than in regular chess.") (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 (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) (Nprelay) ) ) (piece (name Knight) (help "Knight: moves like an `L`, relays L-moves to friendly pieces, cannot be captured") (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 to an empty square. It relays the power to move like itself to friendly pieces it defends. Original or promoted Knights cannot capture and cannot be captured.") (image White "images\Chess\wknight.bmp" Black "images\Chess\bknight.bmp") (moves (Nleap nne) (Nleap nnw) (Nleap sse) (Nleap ssw) (Nleap ene) (Nleap ese) (Nleap wnw) (Nleap wsw) ) ) (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 (slide ne) (slide nw) (slide se) (slide sw) (Nrelay) ) ) (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 (rook-slide n) (rook-slide e) (rook-slide s) (rook-slide w) (Nrelay) ) ) (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 (slide n) (slide e) (slide s) (slide w) (slide ne) (slide nw) (slide se) (slide sw) (Nrelay) ) ) (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 never to a square where it can be captured. It may also `castle` with the Rook if neither the Rook nor King has moved yet and there is nothing in between them. In castling the King moves two squares nearer the Rook and the Rook leaps to the far side of the King. You may not castle out of or through check, or if the King or Rook involved has previously moved.") (image White "images\Chess\wking.bmp" Black "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) (O-O) (O-O-O) ) ) (loss-condition (White Black) (checkmated King) ) ) ;**************************** Transparent N-Relay ********************************* (define tslide ($1 (while (or empty? (piece? Knight)) (if empty? add) $1) (verify not-friend?) add)) (define trook-slide ( $1 (while (or empty? (piece? Knight)) (set-attribute never-moved? false) (if empty? add) $1) (verify not-friend?) (set-attribute never-moved? false) add )) (variant (title "Transparent N-Relay") (description "Transparent N-Relay\\ The rules of N-Relay Chess are in effect, except that Queens, Rooks and Bishops can attack through a square occupied by a Knight. They cannot however stop on that square.") (history "Transparent N-Relay was created and implemented for the Zillions-of-Games engine by Pierre Tourigny in August 1999.\\I wanted a variant of N-Relay where Knights were not immovable shields.") (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 (tslide ne) (tslide nw) (tslide se) (tslide sw) (Nrelay) ) ) (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 (trook-slide n) (trook-slide e) (trook-slide s) (trook-slide w) (Nrelay) ) ) (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 (tslide n) (tslide e) (tslide s) (tslide w) (tslide ne) (tslide nw) (tslide se) (tslide sw) (Nrelay) ) ) ) ;**************************** Double-Edged N-Relay ********************************* (define dNrelay ( (if (or (piece? Knight nne) (piece? Knight nnw) (piece? Knight sse) (piece? Knight ssw) (piece? Knight ene) (piece? Knight ese) (piece? Knight wnw) (piece? Knight wsw) ) (if (on-board? nne) nne (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? nnw) nnw (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? sse) sse (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? ssw) ssw (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? ene) ene (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? wnw) wnw (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? ese) ese (if (and not-friend? (not-piece? Knight)) add) back) (if (on-board? wsw) wsw (if (and not-friend? (not-piece? Knight)) add)) ) )) (define dNprelay ( (if (or (piece? Knight nne) (piece? Knight nnw) (piece? Knight sse) (piece? Knight ssw) (piece? Knight ene) (piece? Knight ese) (piece? Knight wnw) (piece? Knight wsw) ) (if (on-board? nne) nne (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? nnw) nnw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? ene) ene (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? wnw) wnw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? sse) sse (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? ssw) ssw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? ese) ese (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add) back) (if (on-board? wsw) wsw (if (and not-friend? (not-in-zone? nopawn) (not-piece? Knight)) add)) ) )) (variant (title "Double-Edged N-Relay") (description "Double-Edged N-Relay\\ The rules of N-Relay Chess are in effect, except that Knights also relay Knight-moves to the enemy pieces they attack.") (history "Double-Edged N-Relay was created and implemented for the Zillions-of-Games engine by Pierre Tourigny in August 1999.") (strategy "You control the placement of two of the four Knights. Place them so that they help you more than they help your opponent.") (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 (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) (dNprelay) ) ) (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 (slide ne) (slide nw) (slide se) (slide sw) (dNrelay) ) ) (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 (rook-slide n) (rook-slide e) (rook-slide s) (rook-slide w) (dNrelay) ) ) (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 (slide n) (slide e) (slide s) (slide w) (slide ne) (slide nw) (slide se) (slide sw) (dNrelay) ) ) ) ;********************************** N-Relay Bump *************************************** (define bking-shift ( $1 (verify not-friend?) (set-attribute never-moved? false) (if (not-piece? Knight) add else (if (empty? $1) cascade from $1 to add)) )) (define bslide ( $1 (while empty? add $1) (verify enemy?) (if (not-piece? Knight) add else (if (empty? $1) cascade from $1 to add)) )) (define brook-slide ( $1 (while empty? (set-attribute never-moved? false) add $1) (verify not-friend?) (set-attribute never-moved? false) (if (not-piece? Knight) add else (if (empty? $1) cascade from $1 to add)) )) (define bPawn-capture ( $1 (verify enemy?) (if (not-piece? Knight) (if (in-zone? promotion-zone) (add Knight Bishop Rook Queen) else add) else (if (empty? $1) cascade from $1 to add)) ) ) (variant (title "N-Relay Bump") (description "N-Relay Bump\\ The rules of N-Relay Chess are in effect, except that, while Knights are still invulnerable, pieces can 'bump' them away if the square behind the Knight is empty. The piece then takes the Knight's place and the Knight is pushed to the empty square. Pieces can only bump in the direction they capture. knights cannot bump.") (history "N-Relay Bump was created and implemented for the Zillions-of-Games engine by Pierre Tourigny in August 1999.") (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 (bPawn-capture nw) (bPawn-capture ne) (Pawn-move) (Nprelay) ) ) (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 (bslide ne) (bslide nw) (bslide se) (bslide sw) (Nrelay) ) ) (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 (brook-slide n) (brook-slide e) (brook-slide s) (brook-slide w) (Nrelay) ) ) (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 (bslide n) (bslide e) (bslide s) (bslide w) (bslide ne) (bslide nw) (bslide se) (bslide sw) (Nrelay) ) ) (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 never to a square where it can be captured. It may also `castle` with the Rook if neither the Rook nor King has moved yet and there is nothing in between them. In castling the King moves two squares nearer the Rook and the Rook leaps to the far side of the King. You may not castle out of or through check, or if the King or Rook involved has previously moved.") (image White "images\Chess\wking.bmp" Black "images\Chess\bking.bmp") (attribute never-moved? true) (moves (bking-shift n) (bking-shift e) (bking-shift s) (bking-shift w) (bking-shift ne) (bking-shift nw) (bking-shift se) (bking-shift sw) (O-O) (O-O-O) ) ) ) ;********************************** N-Relay Switch *************************************** (define sNleap ($1 (verify not-friend?) (if empty? add else cascade from back (if (and (or (not-piece? Knight $1) not-last-from? (not-last-to? $1)) (or (not-piece? Pawn $1) (not-in-zone? nopawn))) to add)))) (variant (title "N-Relay Switch") (description "N-Relay Switch\\ The rules of N-Relay Chess are in effect, except for the following.\\While Knights are still invulnerable, pieces can 'bump' them away if the square behind the Knight is empty. The piece then takes the Knight's place and the Knight is pushed to the empty square. Pieces can only bump in the direction they capture. Knights cannot bump.\\Knights can switch places with an enemy piece. As in Ko positions in Go, a Knight cannot immediately switch a Knight that just switched it. It can however switch it after an intervening move.\\Because the Zillions engine counts a switch as an attack, the game continues until the King is actually captured, but it should really end at checkmate in over-the-board play.") (history "N-Relay Switch was created and implemented for the Zillions-of-Games engine by Pierre Tourigny in August 1999.") (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 (bPawn-capture nw) (bPawn-capture ne) (Pawn-move) (Nprelay) ) ) (piece (name Knight) (help "Knight: moves like an `L`, relays L-moves to friendly pieces, cannot be captured") (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 to an empty square. It relays the power to move like itself to friendly pieces it defends. Original or promoted Knights cannot capture and cannot be captured.") (image White "images\Chess\wknight.bmp" Black "images\Chess\bknight.bmp") (moves (sNleap nne) (sNleap nnw) (sNleap sse) (sNleap ssw) (sNleap ene) (sNleap ese) (sNleap wnw) (sNleap wsw) ) ) (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 (bslide ne) (bslide nw) (bslide se) (bslide sw) (Nrelay) ) ) (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 (brook-slide n) (brook-slide e) (brook-slide s) (brook-slide w) (Nrelay) ) ) (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 (bslide n) (bslide e) (bslide s) (bslide w) (bslide ne) (bslide nw) (bslide se) (bslide sw) (Nrelay) ) ) (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 never to a square where it can be captured. It may also `castle` with the Rook if neither the Rook nor King has moved yet and there is nothing in between them. In castling the King moves two squares nearer the Rook and the Rook leaps to the far side of the King. You may not castle out of or through check, or if the King or Rook involved has previously moved.") (image White "images\Chess\wking.bmp" Black "images\Chess\bking.bmp") (attribute never-moved? true) (moves (bking-shift n) (bking-shift e) (bking-shift s) (bking-shift w) (bking-shift ne) (bking-shift nw) (bking-shift se) (bking-shift sw) (O-O) (O-O-O) ) ) (loss-condition (White Black) (pieces-remaining 0 King) ) )