The tick number starting at 0. Each new state is 1 more than the last. -1 on a board from make_pseudo_move.
ChessGameState.board
ChessBoard
An object representing the state of the board at this point in the chess game.
ChessGameState.turn
str
The player to move. 'w' if it is white's turn to move and 'b' when it is black's turn to move.
ChessGameState.turn_num
int
The number of executed moves.
ChessGameState.last_move
str
The last move made in this game, in UCI. None at the start of the game.
ChessGameState.moves
list[str]
A list of every move made in this game, oldest first, in UCI. Empty at the start of the game.
ChessGameState.time_left
numpy.ndarray
Seconds left on each chess clock. ChessGameState.time_left[0] is yours and ChessGameState.time_left[1] is your opponent's. Only the clock of the player to move runs, and it is measured each time you read it, going negative once it runs out. Is None on a board from make_pseudo_move.
ChessGameState.all_valid_moves
list[str]
A list of strings for every valid move for the current game state, each written in UCI.
True if this position ends the game, otherwise False. Only a board from make_pseudo_move can be True
ChessGameState.in_check
bool
True if the active color is in check, otherwise False.
ChessGameState.winner
str
'w' if white has won, 'b' if black has won, or 'draw' if the game ended in a draw, otherwise None. Only a board from make_pseudo_move can be not None
ChessGameState.endgame_type
str
'checkmate', 'stalemate', 'insufficient_material', 'fifty_move_rule' or 'repetition' if the game is over, otherwise None. Only a board from make_pseudo_move can be not None
ChessBoard
An object representing the board of a chess game. Index-able with a square’s name, like ‘e4’, or matrix indices. If a cell does not have a piece on it, None will be returned.
Attribute
Type
Description
ChessBoard.array
numpy.ndarray
The board as a numpy array.
ChessBoard.pieces
ChessPieces
A ChessPieces object containing the pieces on the board.
ChessPieces
An iterable of ChessPiece objects with useful helper methods. Can be indexed by a lowercase 'w' or 'b' to get all pieces of the indexed color, or by uppercase letters corresponding to piece type.
Operation
Returns
Description
ChessPieces + ChessPieces
ChessPieces
Concatenates both sets of chess pieces into a new ChessPieces object.
Method
Returns
Description
ChessPieces.get_color(color)
ChessPieces
Returns a new ChessPieces object containing all pieces of the specified color. (Equivalent to indexing with 'w' or 'b')
ChessPieces.get_piece_type(piece_type)
ChessPieces
Returns a new ChessPieces object containing all pieces of the specified type. Valid piece types are 'R','N','B','P','Q', and 'K'. (Equivalent to indexing with uppercase letter)
ChessPieces.get_valid_moves()
list[str]
A list of all the possible moves using the pieces contained in the object, in UCI.
ChessPieces.get_numpy_bitboard()
numpy.ndarray
A 64 element numpy array of 1's and 0's describing the locations of the pieces on a flattened 8x8 chess board.
ChessPiece
A simple object representing a chess piece.
Attribute
Type
Description
ChessPiece.type
str
An uppercase letter for the piece type: 'R', 'N', 'B', 'P', 'Q' or 'K'.
ChessPiece.color
str
'w' if the piece is white, 'b' if the piece is black.
ChessPiece.valid_moves
list[str]
A list of the valid moves for this piece, in UCI.
ChessPiece.pos
str
The name of the square the piece is on, like 'e4'.