mwg API
    Preparing search index...

    Interface BitboardState

    Chess on bitboards: the first slice of the tournament engine (item 390).

    Twelve 64-bit boards (pieces[color * 6 + kind], white 0-5, black 6-11, square 0 is a1 exactly like chess.ts), side to move, castling rights, en passant square, the halfmove clock and both king squares. Everything in it is plain data (bigint included), so a position structured-clones into a worker untouched.

    Two implementations of the rules now exist on purpose: chess.ts is the readable reference a minigame runs directly, this one is the fast mutable board a search makes and unmakes millions of times. tests/board-bitboard.test.ts keeps them honest two ways: every legal move of one is a legal move of the other on a suite of positions, and perft counts match the published node counts.

    interface BitboardState {
        castling: number;
        enPassant: number | null;
        halfmove: number;
        kings: [number, number];
        pieces: bigint[];
        turn: ChessSide;
    }
    Index
    castling: number

    castling rights as a mask: 1 white kingside, 2 white queenside, 4 black kingside, 8 black queenside

    enPassant: number | null

    a square a pawn could capture onto, left behind by a double push

    halfmove: number
    kings: [number, number]

    king squares, white then black: maintained on every move, so checks never scan

    pieces: bigint[]

    twelve bitboards: white pawn..king, then black pawn..king

    turn: ChessSide