Chess Project · Part 2

Building the Search Engine

Board representation, PUCT tree search, batched inference, and the bugs that still look like chess.

Encoding the board

The neural network cannot consume a Python chess board directly. Each position becomes a stack of 8×8 feature planes describing pieces, side to move, castling rights, en passant state, and other information needed to distinguish otherwise identical boards.

Monte Carlo Tree Search

Each search repeatedly selects a path, expands a leaf, evaluates it with the network, and backs the value up through the tree. PUCT balances the network prior, the average value already observed, and an exploration bonus for under-visited moves.

Batched inference

Evaluating one leaf at a time wastes the GPU. The implementation gathers leaves from multiple active games, evaluates them as one batch, then returns the results to the corresponding trees.

Debugging perspective

The most common failures were not syntax errors. They were sign errors, perspective errors, legal-move-mask mistakes, and mismatched action encodings. Each can produce plausible games while quietly destroying the learning signal.