Things I make

A whole board.
One little number.

Rook is my Python chess engine. One of its building blocks is a wonderfully compact idea: representing a chessboard with 64 bits.

Independent projectPythonExplore the source

Try thinking like a board.

Each square can be either on or off. A collection of selected squares fits into a single 64-bit integer. Here, sixteen bits are on: every white piece on its starting square.

0x000000000000ffff16 bits on

Each lit square is a 1, and each hex digit holds four squares. Read right to left: a1 is bit 0, h8 is bit 63.

This is a representation explorer, not a running chess engine.

Why bits?

A chessboard has exactly 64 squares. Mapping one bit to each square lets an engine describe a set of positions compactly. Bitwise operations can combine those sets, find overlaps, or remove positions.

This explorer uses a1 as bit 0 and h8 as bit 63. The value below the board is hexadecimal: a short way to write the same 64 bits. Toggle a square twice and you return to the original value.

The representation is only the beginning.

Rook’s public documentation describes a piece-centric model with bitboards, alongside the larger tasks of move generation, search, and evaluation. Representing a position is one part of the problem; deciding what to do with it is another.

The interesting tradeoff is readability. A bitwise operation can express a lot in very little code, but the mapping needs to be explicit. A visual board gives those otherwise abstract numbers somewhere to live.

Go a little deeper.

The Rook repository contains the code and documentation. This small browser experiment illustrates the representation idea; it does not benchmark engine strength or mirror every internal implementation detail.

Another rabbit hole: Wordle