;Triplets ;Implemented by Doug Chatham, November 5, 2001 ; *** Chess ; *** Copyright 1998-2000 Zillions Development ; v.1.2 ; You need to purchase Zillions of Games to load this rules file ; Visit the Zillions web site at http://www.zillions-of-games.com ; Special macros to make this script handle En Passant correctly : ; (the standard Zillions Chess En Passant cannot handle the double ; and treble moves of Triplets) ; This program 'marks' Pawns (by turning them into 'VictimPawns') ; that make an initial move of two squares, in ; order to indicate that they can be captured en-passant in the next turn ; After that next turn is over, the Pawn must be unmarked. A dummy player ; ?Fixer is assigned the task of unmarking. The 'fixpawn' command ; turns a VictimPawn back into a Pawn. (define fixpawn ((change-type Pawn) add)) ; If there are no VictimPawn that need fixed, do nothing. (define Wdonothing ((verify (and (not-piece? VictimPawn a4) (not-piece? VictimPawn b4)(not-piece? VictimPawn c4)(not-piece? VictimPawn d4)(not-piece? VictimPawn e4)(not-piece? VictimPawn f4)(not-piece? VictimPawn g4)(not-piece? VictimPawn h4))) add)) (define Bdonothing ((verify (and (not-piece? VictimPawn a5) (not-piece? VictimPawn b5)(not-piece? VictimPawn c5)(not-piece? VictimPawn d5)(not-piece? VictimPawn e5)(not-piece? VictimPawn f5)(not-piece? VictimPawn g5)(not-piece? VictimPawn h5))) add)) ; A pawn in the dummy position 3rd indicates that neither king has been moved. ; A bishop indicates that White but not Black has moved the king. ; A rook indicates that both sides have moved their kings (so a castle is no ; longer possible). (define fix3rd (if (piece? Pawn 3rd) (change-type Bishop 3rd) else (if (piece? Bishop 3rd) (change-type Rook 3rd)))) ; Actual move macros ; Pi, K, and P are dummy positions that indicate whether a player has ; made his/her Piece, King, or Pawn moves for his/her current turn. ; If Pi (resp. K, P) is the player's color, then the player has made his/her ; Piece (resp. King, Pawn) move for that turn. (define leap1 ((verify (not-friend? Pi)) $1 (verify not-friend?) (change-owner Pi) add) ) (define leap2 ((verify (not-friend? Pi)) $1 $2 (verify not-friend?) (change-owner Pi) add) ) ;Note: According to the rules of Triplets, a King can move into check ; as long as it is not still in check at the end of the player's turn (define king-shift ((verify (not-friend? K)) $1 (verify not-friend?) (fix3rd) (change-owner K) add) ) (define slide ((verify (not-friend? Pi)) $1 (while empty? (change-owner Pi) add $1) (verify not-friend?) (change-owner Pi) add)) (define rook-slide ( (verify (not-friend? Pi)) $1 (while empty? (set-attribute never-moved? false) (change-owner Pi) add $1) (verify not-friend?) (set-attribute never-moved? false) (change-owner Pi) add )) ; A castle is only possible in the 3rd move, when the king must make its ; first move. Also, only a king-side castle is possible in Triplets. (define O-O ( (verify (not-friend? K)) (verify (or (piece? Pawn 3rd)(piece? Bishop 3rd))) e ; KB1 (verify empty?) e ; KN1 (verify empty?) cascade e ; KR1 (verify (and friend? (piece? Rook) never-moved?) ) from back ; K1 e ; KB1 to (set-attribute never-moved? false) e ; KN1 (set-attribute never-moved? false) (change-owner K) (fix3rd) add ) ) (define Pawn-add (if (in-zone? promotion-zone) (change-owner P) (add Knight Bishop Rook Queen) else (change-owner P) add) ) (define Pawn-move ( (verify (not-friend? P)) n (verify empty?) (Pawn-add) (verify (in-zone? third-rank)) n (verify empty?) (change-owner P) (change-type VictimPawn) add ) ) (define Pawn-capture ( (verify (not-friend? P)) $1 (verify enemy?) (Pawn-add) ) ) (define En-Passant ( (verify (not-friend? P)) $1 (verify enemy?) (verify (piece? VictimPawn)) capture n to n (change-owner P) add ) ) (define Board-Definitions (image "images\Chess\Chess8x8.bmp") (grid (start-rectangle 5 5 53 53) (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) ) ) (dummy P Pi K 3rd) (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 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) ) ) (game (title "Triplets") (description "In this chess variant, each player first makes a pawn move, then a double move consisting of a pawn move and a non-king, non-pawn (i.e. _piece_) move, in either order. Each subsequent move is a triple move consisting of a pawn move, a piece move, and a king move (in any order). A player loses when checkmated or when he/she cannot complete any part of his/her turn.") (history "This variant was invented by chess problemist Adam Sobey and publicized by D. B. Pritchard in the Encyclopedia of Chess Variants.") (strategy "Most games of Triplets end when one of the players runs out of pawn moves. Keep this in mind.") (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 ?Fixer) (turn-order (White pawn-move) (Black pawn-move) (?Fixer White Wfix)(White not-king-move) (White not-king-move) (?Fixer Black Bfix) (Black not-king-move) (Black not-king-move) repeat (?Fixer White Wfix) (White not-fix-move) (White not-fix-move) (White not-fix-move) (?Fixer Black Bfix) (Black not-fix-move) (Black not-fix-move) (Black not-fix-move)) ; Bfix (resp. Wfix) are only for the ?Fixer to repair Black ; (resp. White) VictimPawns at the ; appropriate times and for the ?Fixer to do nothing at all other times ; A not-fix-move is an ordinary move of a piece ; A not-king-move is part of the second turn's doublet Piece-and-Pawn move ; A pawn-move is a move of just a pawn (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 3rd P K Pi) (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. On rare occasions Pawns can also execute a move called `En Passant`, or `in passing`. This allows a Pawn to take an enemy Pawn that has just moved two squares.") (image White "images\Chess\wpawn.bmp" Black "images\Chess\bpawn.bmp") (moves (move-type pawn-move) (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) (En-Passant e) (En-Passant w) (move-type not-king-move) (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) (En-Passant e) (En-Passant w) (move-type not-fix-move) (Pawn-capture nw) (Pawn-capture ne) (Pawn-move) (En-Passant e) (En-Passant w) ) ) (piece (name VictimPawn) (image White "images\Chess\wpawn.bmp" Black "images\Chess\bpawn.bmp") (notation "Pawn") (moves (move-type Wfix) (fixpawn) (move-type Bfix) (fixpawn) )) (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 not-king-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 not-fix-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) ) ) (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 not-king-move) (slide ne) (slide nw) (slide se) (slide sw) (move-type not-fix-move) (slide ne) (slide nw) (slide se) (slide 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 not-king-move) (rook-slide n) (rook-slide e) (rook-slide s) (rook-slide w) (move-type not-fix-move) (rook-slide n) (rook-slide e) (rook-slide s) (rook-slide 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 not-king-move) (slide n) (slide e) (slide s) (slide w) (slide ne) (slide nw) (slide se) (slide sw) (move-type not-fix-move) (slide n) (slide e) (slide s) (slide w) (slide ne) (slide nw) (slide se) (slide 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 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 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 (move-type king-move) (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) (move-type not-fix-move) (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) (move-type Wfix) (Wdonothing) (move-type Bfix) (Bdonothing) ) ) (loss-condition (White Black) stalemated) (loss-condition (White Black) (checkmated King)) )