Complete state of a chess game: board tuple, side to move, castling rights
(bit flags wk = 1, wq = 2, bk = 4, bq = 8), en-passant square,
half/fullmove clocks, position history, Zobrist hash and cached king squares.
Build positions with new/1 (FEN), advance them with make_move/2 (struct
moves) or advance_position/6 (packed moves on raw tuples, used by perft),
and query terminal state with checkmate?/1, stalemate?/1 and draw?/1.
Summary
Functions
Returns true if the game is over by checkmate.
Returns true if the game is drawn.
Returns true if the given castling right is present.
Returns true if the current side to move is in check.
Executes a move on the game state.
Executes a packed move on the game state.
Executes a packed move using the canonical transition pipeline without extending history.
Creates a new game from a FEN string.
Returns true if the game is over by stalemate.
Verifies if a pseudo-legal move leaves the mover in check.
Returns true if a packed pseudo-legal move is legal.
Types
@type king_pos() :: {Echecs.Board.square() | nil, Echecs.Board.square() | nil}
@type t() :: %Echecs.Game{ board: Echecs.Board.board_tuple(), castling: non_neg_integer(), en_passant: Echecs.Board.square() | nil, fullmove: pos_integer(), halfmove: non_neg_integer(), history: [non_neg_integer()], king_pos: king_pos(), turn: Echecs.Piece.color(), zobrist_hash: non_neg_integer() }
Functions
Returns true if the game is over by checkmate.
Returns true if the game is drawn.
@spec has_right?(non_neg_integer(), Echecs.Piece.color(), :kingside | :queenside) :: boolean()
Returns true if the given castling right is present.
Returns true if the current side to move is in check.
@spec make_move(t(), Echecs.Move.t()) :: t()
Executes a move on the game state.
Executes a packed move on the game state.
Executes a packed move using the canonical transition pipeline without extending history.
Creates a new game from a FEN string.
Returns true if the game is over by stalemate.
@spec verify_move(t(), Echecs.Move.t()) :: boolean()
Verifies if a pseudo-legal move leaves the mover in check.
Returns true if a packed pseudo-legal move is legal.