Returns the board as an 8x8 array of Piece | undefined, indexed
[rank][file] with board()[0] = rank 1 (a1-h1) and board()[7]
= rank 8.
Returns the piece on the given square, or undefined if the square
is empty.
Returns the list of moves played so far. Undone moves are not included.
Returns true if the active color's king is in check.
Returns true if the active color is in checkmate.
Returns true if the position is a draw by any of: 50-move rule,
insufficient material, stalemate, or threefold repetition.
Returns true if the game is over by checkmate or draw.
Returns true if the active color has no legal moves and is not in
check.
Applies a move and returns this for chaining. Clears the redo
stack.
Returns all legal moves for the active color. If a square is given, returns only the legal moves for the piece on that square.
Optionalsquare: Returns the color whose turn it is to move: 'white' or 'black'.
Steps back one move. No-op at the start of the game.
A mutable chess game with legal move generation, undo/redo, and game-state detection.
Example