Bitboard

A representation with 64 zero-or-one indicators, one per square, marking which squares belong to a chosen set.

Explanation

A bitboard represents a set of chessboard squares with a 64-bit number. A bit is a unit that can hold only 0 or 1. Because a chessboard has 64 squares, one bit can be assigned to every square.

White-pawn mask

8
7
6
5
4
3
2
a1
b
c
d
e
f
g
h
The active bits correspond to the White pawns on , , , and .
One bit per square

Fixed local convention: indicators are read by ranks from through , then through , continuing down to and . A 1 marks membership in the set. Displayed set, White pawns: 00000000/00000000/00000000/00000000/00000000/00101000/10000001/00000000. The side to move and the other FEN data are not part of this mask.

A value of 1 does not always mean that a piece is present. It means that the square belongs to the set described by that bitboard. A bitboard might mark all White pawns, every square attacked by a knight, all occupied squares, or any other useful group.

Knight-attack mask

8
7
6
5
4
3
2
a1
b
c
d
e
f
g
h
The eight geometric destinations of the knight on form the set even though they are empty.
Ones without pieces

The same rank-order convention is retained. Displayed set, squares attacked by the White knight on : 00000000/00000000/00101000/01000100/00000000/01000100/00101000/00000000. The ones describe a geometric property even when no piece occupies those squares.

A usually maintains several bitboards at once. Bitwise operations, which combine the zeros and ones directly, can intersect sets, unite them, remove squares, or shift patterns with very few processor instructions. This supports fast move and attack generation.

Attack and occupancy intersection

8
7
6
5
4
3
2
a1
b
c
d
e
f
g
h
and belong to both A and B: the rook on attacks them and a Black piece occupies them.
Result of A ∩ B

Using the declared rank-order convention, A is the set of squares attacked by the White rook on and B is the set of squares occupied by Black pieces. The displayed set is the intersection of A and B: 00000000/00000000/00000000/00010000/00000000/00000000/00000000/00000001. The active bits correspond to and . The Black king on belongs to B but not to A.

What one bitboard does not store by itself

  • Every piece type, unless other bitboards provide that separation.
  • Which side is to move.
  • rights, meaning whether the special king-and-rook move is still allowed, and en passant availability, meaning whether a pawn can make that special capture.

A complete position combines those facts with several sets. A bitboard is also not a search method such as ; it is a representation of information.

Common confusions

A bitboard and the complete board state

A bitboard normally describes one set of squares. A complete position combines several sets with other state information.

Bitboard and bitbase

A bitboard represents squares in one position; a bitbase stores results for many endgame positions.

View term

Sources

  1. 1.Bitboards, Chess Programming Wiki
  2. 2.bitboard.h, Stockfish

Related terms

© 2026 MindZug