Chess, a mathematical definition Jeroen Warmerdam, j.h.a.warmerdam@planet.nl August 2011, Voorschoten, The Netherlands, Introduction We present a mathematical definition for the game of chess, based on the FIDE LAWS of CHESS E.I.01. We strived to be precise and concise and avoided to be tricky. We use notions from logic and set theory, like functions and powersets. Our main goal is to define valid moves. We did not use game theoretic notions like players and gains and losses. Also claims, clocks, the act of moving, etc are not dealt with in this article. Basics For example square e2 corresponds to (5,2) and the white rook corresponds to. We identify the color with the direction of play: For, we denote the opposite color by. For let be defined by A position is a mapping from to. The initial position is defined by ip(.,8) (-1,R) (-1,N) (-1,B) (-1,Q) (-1,K) (-1,B) (-1,N) (-1,R) ip(.,7) (-1,P) (-1,P) (-1,P) (-1,P) (-1,P) (-1,P) (-1,P) (-1,P) ip(.,6) empty empty empty empty empty empty empty empty ip(.,5) empty empty empty empty empty empty empty empty ip(.,4) empty empty empty empty empty empty empty empty ip(.,3) empty empty empty empty empty empty empty empty ip(.,2) (1,P) (1,P) (1,P) (1,P) (1,P) (1,P) (1,P) (1,P) ip(.,1) (1,R) (1,N) (1,B) (1,Q) (1,K) (1,B) (1,N) (1,R) ip(1,. ) ip(2,. ) ip(3,. ) ip(4,. ) ip(5,. ) ip(6,. ) ip(7,. ) ip(8,. ) This is the normal initial position. All definitions, except for, will be valid for Chess960 as well.
2/8 Games A game is a finite sequence of positions. Let be the set of all games of moves 1, defined by induction as follows. It remains to define 2. Games over Checkmate: The game is over when and. The player playing color has lost the game and the opponent has won the game. will be defined later. Stalemate: The game Dead position: The game king: is over and the result is drawn when and. is drawn when neither player can checkmate the opponent s i m: Threefold repetition 3,4 : The game is drawn after three times the same position: Fifty-move rule 3 : The game is drawn after 50 moves without progress: denotes the number of empty squares in position. will be defined later. 1 Here move refers to one turn by white or black. In the chess community, a move normally means a turn by both white and black. 2 is the powerset of, i.e. the set of all subsets of. So is some set of positions, in particular the set of all positions that can be reached from by valid moves. For en passant capture and castling we include the whole history of the match. 3 According to the FIDE LAWS of CHESS, a player must claim draw before he/she moves. 4 Here not only all possible moves must be equal in the three positions, but all possible moves must be equal after any continuation. The intention of the LAWS are not clear on this point.
3/8 Moves on an empty board When moving from square to, and must be unequal: Before we define moves of all pieces, it helps to define the exceptional first move of a pawn. Now we can define moves and attacks on an empty board as subsets of. For all but the pawn, the normal moves coincide with attacks. For the pawn, the attack is like the bishop but only one rank forward. For convenience, we extend the domains of and to by.
4/8 Moves in a position When we move a piece from one square to another, the square in between must be empty: We will reuse these mappings when defining castling. Note that knight moves are members of, as there are no squares in between the origin and destination according to these definitions. Now we take the moving piece into account: where A normal move by white or black is a non-capture or a capture, where the original square contains a piece of the right color: When we do a move from to, this is how the position changes: For Chess960 castling, we extend the domain of to by.
5/8 For en passant capture and castling, we need another change of position, which will be defined later. For promotion, we use a function that changes the position when a pawn is on the first or last rank. So if then is the same as, but for pawns on the first or last file. These are changed in a rook, bishop, knight or queen of the same color. Now we can define normal moves in a position by a player as a set of new positions: We still have to take care for a king under attack. When we postpone the definition of EnPassant en Castling, we are ready to define:
6/8 En passant Explanation:, so we move a pawn; so we move like a pawn would attack; so in the same rank and neighboring file there is an opposite pawn and the move from to was a move of that pawn two squares forward.
7/8 Castling The mapping is a move of the king followed by a move of the rook. The set contains all Castling movements for normal chess as well as Chess960. Note that the castling rook and king always change order. (i) (ii) (iii) (iv) (v) Explanation: (i) Condition (i) means we move the king and rook of the right color and these pieces did not move in the game so far; (ii) In Chess960 it is possible to castle without moving the king. Condition (ii) prevents a second castle by the same player. refers to a function that is not yet defined. Formally and are defined by induction to ; (iii) All square between the king s initial and final squares (including the final square) must be empty, except for the castling rook; (iv) All square between the castling rook s initial and final squares (including the final square) must be empty, except for the king; (v) All squares between the king s initial and final squares (including the initial and final squares) must not be attacked by an opponent s piece. Now we are ready to define castling:
8/8 Chess 960 As we have said before, all definitions above apply to chess 960 as well. We only need to redefine the set of possible initial positions. Let itself. be the set of all possible permutation of {1..8}, i.e. the set of all bijections from {1..8} to (i) (ii) (iii) (iv) Explanation: (i) The 2 nd to 7 th rank are equal to the initial position of regular chess; (ii) The first rank contains the same pieces as in regular chess, but the order may be different. The black pieces are reordered in the same way as the white pieces; (iii) The king is placed between the two rooks; (iv) The number of square between the two white bishops is even, so they are placed on opposite-colored squares (not defined here);