Optionalboard: ReadonlyMap<Piece placement. Defaults to an empty board.
Optionaloptions: PositionOptionsTurn, castling rights, en passant, and move counters.
ReadonlycastlingWhich castling moves remain available.
ReadonlyenEn passant target square (rank 3 or 6), if any.
ReadonlyfullmoveGame turn counter — increments after each black move.
ReadonlyhalfmoveHalf-moves since last pawn advance or capture (fifty-move rule).
ReadonlyturnSide to move.
Zobrist hash of the position as a 16-character hex string. Computed once
and cached. Uses the Polyglot standard keys from @echecs/zobrist.
Whether the side to move is in check. Computed once and cached.
Whether the position is a draw by insufficient material (FIDE rules): K vs K, K+B vs K, K+N vs K, or K+B(s) vs K+B(s) with same-color bishops.
Whether the position is legally reachable: exactly one king per side, no pawns on ranks 1 or 8, and the side not to move is not in check.
Returns the piece on the given square, or undefined if empty.
Returns a new position with the given changes applied. Fields not provided are carried over from the source.
Optionalchanges: DeriveOptionsReturns a map of all pieces on the board, optionally filtered by color.
Optionalcolor: ColorFrom square, return all squares the given piece can reach on the
current board. Filters out same-color pieces. For sliding pieces, stops
before friendlies and includes enemy pieces. For pawns, includes pushes
(blocked by any piece), captures (enemy only), and en passant.
An immutable chess position — board state, turn, castling rights, en passant square, and move counters.
Query the position with getters and methods. Produce new positions with derive.