Chess board as a 15-element tuple of 64-bit integer bitboards.
Layout
Elements 0..5 hold the white pawns, knights, bishops, rooks, queens and
king; 6..11 the black pieces in the same order; 12, 13 and 14 cache
the white, black and combined occupancies.
Square 0 is a8 and square 63 is h1 (1 <<< ((7 - rank) * 8 + file)),
so white pawns advance toward lower indices. Use at_tuple/2 for piece lookup and
make_move_on_board_tuple/3 for the allocation-free move application used
by the move generator's fast path.
Summary
Functions
Fast piece lookup on a tuple board. Returns {color, type} or nil.
Returns true if the square sq is attacked by attacker_color.
Accepts both tuple and struct boards.
Applies a move to the bitboards only. Used for fast legality checking. Returns the updated board tuple. Single-write: destructures once, constructs one new tuple.
Types
@type square() :: 0..63
@type t() :: %Echecs.Board{ all_pieces: term(), black_bishops: term(), black_king: term(), black_knights: term(), black_pawns: term(), black_pieces: term(), black_queens: term(), black_rooks: term(), white_bishops: term(), white_king: term(), white_knights: term(), white_pawns: term(), white_pieces: term(), white_queens: term(), white_rooks: term() }
Functions
@spec at(t() | board_tuple(), square()) :: piece()
Fast piece lookup on a tuple board. Returns {color, type} or nil.
Returns true if the square sq is attacked by attacker_color.
Accepts both tuple and struct boards.
Applies a move to the bitboards only. Used for fast legality checking. Returns the updated board tuple. Single-write: destructures once, constructs one new tuple.