(define "HasNeverMoved" (= (state at:(mapEntry #1 (mover))) 1) ) (define "PieceHasMoved" (set State at:#1 0) ) (define "RememberPieceHasMoved" (then (if (= (state at:(last To)) 1) ("PieceHasMoved" (last To)) ) ) ) (define "CaptureToPiece" (apply (if ("IsEnemyAt" (to)) (remove (to) ) ) ) ) (define "KingNotCheckedAndToEmpty" (and (is Empty (to)) (not ("IsInCheck" "King" Mover at:(to))) ) ) (define "DecideToCastle" (move Slide (from (mapEntry #1 (mover))) #2 (between (exact #3) if:#4 ) (to if:True (apply ("PieceHasMoved" (from))) ) #5 ) ) (define "CastleRook" (slide (from (mapEntry #1 (mover))) #2 (between (exact #3) if:#4 ) (to if:True (apply ("PieceHasMoved" (from))) ) ) ) (define "SmallCastling" ("DecideToCastle" "King" E 2 "KingNotCheckedAndToEmpty" (then ("CastleRook" "RookRight" W 2 True))) ) (define "BigCastling" ("DecideToCastle" "King" W 2 "KingNotCheckedAndToEmpty" (then ("CastleRook" "RookLeft" E 3 True))) ) (define "SetEnPassantLocation" (then (set Pending (ahead (last To) Backward)) ) ) (define "InLocationEnPassant" (and (is Pending) (= (to) (value Pending)) ) ) (define "EnPassant" (move Step (directions {FR FL}) (to if:"InLocationEnPassant") (then (remove (ahead (last To) Backward) ) ) ) ) (define "InitialPawnMove" (if (is In (from) (sites Start (piece (what at:(from))))) ("DoubleStepForwardToEmpty" "SetEnPassantLocation") ) ) //------------------------------------------------------------------------------ (game "Scachs" ("TwoPlayersNorthSouth") (equipment { (board (square 8)) ("ChessPawn" "Pawn" (or "InitialPawnMove" "EnPassant" ) (then (if (and ("IsOffBoard" (where "Queen" Mover)) (is In (last To) (sites Mover "Promotion"))) (promote (last To) (piece {"Queen"}) Mover) ) ) ) ("ChessRook" "Rook" ~ ("RememberPieceHasMoved")) (piece "King" Each (or (if (and (not ("IsInCheck" "King" Mover)) ("HasNeverMoved" "King")) (move Slide (between (exact 2)) (to if:(is Empty (to))) ) ) ("StepToNotFriend") "RememberPieceHasMoved" ) ) ("ChessBishop" "Bishop") ("ChessKnight" "Knight") (piece "Queen" Each (move Slide (to if:(and (not ("IsPieceAt" "Queen" Next (to))) ("IsEnemyAt" (to))) "CaptureToPiece" ) ) ) (map "King" {(pair 1 "E1") (pair 2 "E8")}) (map "RookLeft" {(pair 1 "A1") (pair 2 "A8")}) (map "RookRight" {(pair 1 "H1") (pair 2 "H8")}) (regions "Promotion" P1 (sites Top)) (regions "Promotion" P2 (sites Bottom)) }) (rules (start { (place "Pawn1" (sites Row 1)) (place "Pawn2" (sites Row 6)) (place "Rook1" {"A1" "H1"} state:1) (place "Knight1" {"B1" "G1"}) (place "Bishop1" {"C1" "F1"}) (place "Queen1" coord:"D1") (place "King1" coord:"E1" state:1) (place "Rook2" {"A8" "H8"} state:1) (place "Knight2" {"B8" "G8"}) (place "Bishop2" {"C8" "F8"}) (place "Queen2" coord:"D8") (place "King2" coord:"E8" state:1) }) (play (do (or (forEach Piece) (if (and ("HasNeverMoved" "King") (not ("IsInCheck" "King" Mover)) ) (or (if (and ("HasNeverMoved" "RookLeft") (can Move ("CastleRook" "RookLeft" E 3 (is Empty (to)))) ) "BigCastling" ) (if (and ("HasNeverMoved" "RookRight") (can Move ("CastleRook" "RookRight" W 2 (is Empty (to)))) ) "SmallCastling" ) ) ) ) ifAfterwards:(not ("IsInCheck" "King" Mover)) ) ) (end { ("Checkmate" "King") (if (= 1 (count Pieces Next)) (result Mover Win)) ("BlockWin") }) ) ) //------------------------------------------------------------------------------ (metadata (info { (description "Scachs is the word for Chess in Catalan. This version of the game is described in the fifteenth century poem. The poem describes the courtship of Venus and Mars through a game of Scachs played between them, observed by Mercury.") (rules " Played on an 8x8 board with pieces with specialized moves: Pawns (8): can move one space orthogonally forward, or two steps orthogonally forward on their first move, capture one space diagonally forward; Rooks (2): can move any number of spaces orthogonally; Bishops (2): can move any number of spaces diagonally; Knight (2): moves in any direction, one space orthogonally with one space forward diagonally; Queens (1): can move any number of spaces orthogonally or diagonally, cannot capture another Queen; Kings (1): can move one space orthogonally or diagonally, but on the first turn may move two squares provided it is not currently in check. The King cannot capture with this move. Castling, En Passant, and Pawn promotion allowed. Pawns promote to Queens when reaching the last row on the board only if that player's Queen has already been captured. An opponent's piece is captured by moving a player's own piece onto a space occupied by the opponent's piece. When a King can be captured on the next turn by an opponent's piece, it is in check. The King must not be in check at the end of the player's turn. If this is not possible, it is checkmate and the opponent wins. If the opponent is reduced to only a king, it is considered a win. Stalemate is also a win for the player causing the stalemate. ") (source "Murray 1913: 781.") (id "1415") (version "1.3.12") (classification "board/war/replacement/checkmate/chess") (credit "Eric Piette") (origin "This game was played in Spain, from around 1475 to 1499.") } ) (graphics { (board Style Chess) }) (ai "Scachs_ai" ) )