(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)) (and (remember Value "CapturedPieces" (what at:(to))) (remove (to)) ) ) ) ) (define "WasCaptured" (is In #1 (values Remembered "CapturedPieces"))) (define "AtLeastAStrongPieceWasCapture" (or { ("WasCaptured" (id "Queen" Mover)) ("WasCaptured" (id "Knight" Mover)) ("WasCaptured" (id "Rook" Mover)) ("WasCaptured" (id "Bishop" Mover)) }) ) (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 "CaptureForwardDiagonal" (move Step (directions {FR FL}) (to if:("IsEnemyAt" (to)) (apply (and (remember Value "CapturedPieces" (what at:(to))) (remove (to)) ) ) ) ) ) (define "PromoteMove" (or { (if ("WasCaptured" (id "Queen" Mover)) (move Promote #1 (piece {"Queen"}) Mover) ) (if ("WasCaptured" (id "Knight" Mover)) (move Promote #1 (piece {"Knight"}) Mover) ) (if ("WasCaptured" (id "Rook" Mover)) (move Promote #1 (piece {"Rook"}) Mover) ) (if ("WasCaptured" (id "Bishop" Mover)) (move Promote #1 (piece {"Bishop"}) Mover) ) } #2 ) ) //------------------------------------------------------------------------------ (game "Korkserschach" ("TwoPlayersNorthSouth") (equipment { (board (square 8)) (piece "Pawn" Each (if (!= (last To) (from)) (or { (if (and ("AtLeastAStrongPieceWasCapture") (is In (from) (sites Mover "Promotion"))) ("PromoteMove" (from) (then (set Pending))) ) "StepForwardToEmpty" "CaptureForwardDiagonal" } (then (and (if (and (is In (last To) (sites Mover "Promotion")) ("AtLeastAStrongPieceWasCapture") ) (moveAgain) ) (if (and ("NewTurn") (<= (count Turns) 2)) (and (set Pending) (moveAgain) ) ) ) ) ) ) ) (piece "Rook" Each (move Slide Orthogonal (to if:("IsEnemyAt" (to)) "CaptureToPiece" ) "RememberPieceHasMoved" ) ) (piece "King" Each (move Step (to if:(not ("IsFriendAt" (to))) "CaptureToPiece" ) "RememberPieceHasMoved" ) ) (piece "Bishop" Each (move Slide Diagonal (to if:("IsEnemyAt" (to)) "CaptureToPiece" ) ) ) (piece "Knight" Each (move Leap "KnightWalk" (to if:(not ("IsFriendAt" (to))) "CaptureToPiece" ) ) ) (piece "Queen" Each (move Slide (to if:("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 (if (and (not (is Pending)) "SameTurn") ("PromoteMove" (last To)) (do (if (is Pending) (or (move Pass) (forEach Piece "Pawn" Mover) ) (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)) ) (then (and (if (or ("IsInCheck" "Queen" P1) ("IsInCheck" "Queen" P2)) (note "Gardez la reine") ) (if (and (= (state at:(where "King" Next)) 1) ("IsInCheck" "King" Next)) ("PieceHasMoved" (where "King" Next)) ) ) ) ) ) (end ("Checkmate" "King")) ) ) //------------------------------------------------------------------------------ (option "Play Rules" args:{ } { (item "Pawn Double Step" < (if (is In (from) (sites Start (piece (what at:(from))))) ("DoubleStepForwardToEmpty") ) > "The pawns can double step from the starting positions." )* (item "No Pawn Double Step" <> "No double step for the pawns.") }) //------------------------------------------------------------------------------ (rulesets { (ruleset "Ruleset/Korkserschach (Described)" { "Play Rules/Pawn Double Step" } variations:{"Play Rules/No Pawn Double Step"} ) }) //------------------------------------------------------------------------------ (metadata (info { (description "Korkserschach is a Chess game played in Germany until the nineteenth century. While it was played, it was considered a lesser, or unofficial, version of the game.") (rules "Played on an 8x8 board with pieces with specialized moves: Pawns (8): can move one space forward, or one space diagonally forward to capture; Players agree at the beginning of the game whether pawns may move two spaces on their first turn. Two pawns may be moved by a player in their first turn of the game. Pawns may only be promoted to a piece that has already been captured. If none have been captured, the pawn must remain in place until a piece has been captured. 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, jumping over any intervening pieces; Queens (1): can move any number of spaces orthogonally or diagonally; Kings (1): can move one space orthogonally or diagonally. A King cannot castle if it has ever been checked. Players capture pieces by moving onto a space occupied by an opponent's piece. A player must say 'Gardez la reine' (Guard the Queen) when the queen is threatened. 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. A player who causes a stalemate loses. ") (source "Murray 1913: 391.") (id "1430") (version "1.3.12") (classification "board/war/replacement/checkmate/chess") (origin "This game was played in Germany, around 1873.") } ) (graphics { (show Check "King") (piece Scale "Pawn" 0.825) (piece Families {"Defined" "Microsoft" "Pragmata" "Symbola"}) (board Style Chess) }) (ai "Korkserschach_ai" ) )