Everett Stenberg

FIELD NOTES / 02 / SELF-LEARNING CHESS

Learn a position.
Search for a move.

A chess engine built around a feedback loop: a neural network guides search, search produces games, and those games train the next network. The challenge is making every link in that loop trustworthy.

34board input planes
4,672possible action slots
2network outputs
1champion to beat

01 / THE LEARNING LOOP

A network proposes. Search investigates.

The project is an AlphaZero-style chess system with a practical starting point: supervised learning from recorded games before self-play. Human moves provide initial policy targets, while game outcomes provide value targets. That gives early searches more direction than a randomly initialized network.

The ambition is to improve through experience rather than hand-author a complete position evaluator. This is an experimental implementation, not a claim to reproduce AlphaZero’s playing strength or training scale.

  1. Champion networkEstimate moves and position value
  2. Guided tree searchInvestigate promising continuations
  3. Self-play + replayStore positions, visits, and outcomes
  4. Train + challengeEvaluate a candidate against the champion
Implementation versus performance

The repository contains self-play, candidate training, and paired-color arena evaluation. These notes describe those mechanisms. A verified Elo rating or a sustained improvement claim would require separate match results.

02 / READING THE BOARD

Two questions, one shared representation.

The board is encoded as a 34 × 8 × 8 tensor. A convolutional stem and a residual tower build features that feed two heads. The policy head scores possible actions. The value head estimates the outcome from the side-to-move perspective, on a scale from −1 to +1.

The documented self-learning setup uses 12 residual blocks and 128 channels. The loaded checkpoint’s metadata determines the actual architecture; defaults elsewhere in the repository are not a reliable substitute.

Representation contract
Input34 planes across an 8 × 8 board
Policy space8 × 8 × 73 = 4,672 action slots
Policy legalityOnly legal moves participate in search
Value outputA scalar bounded by tanh
SearchPUCT with batched neural evaluation

Most action slots are not legal in a given position. The encoder, network output order, and legal-move mask must agree exactly. A correct tensor shape is necessary, but it cannot prove that a move is attached to the right score.

04 / LEARNING FROM GAMES

Search leaves behind a richer lesson than one move.

A recorded human game supplies the move that was played. Self-play can instead supply a distribution over explored moves, derived from visit counts. That distribution becomes a policy target; the eventual game result provides the value target.

The bootstrap pipeline separates large position tensors in HDF5 shards from searchable game metadata in SQLite. The self-play pipeline stores sparse policy targets so replay does not need a dense vector of thousands of actions for every position.

Candidate training can mix recent self-play with human-game rehearsal. The supplied configuration uses a 25% bootstrap mix and retains eight replay iterations. Those settings describe the configured experiment, not a demonstrated optimal recipe.

Why keep older examples?

Training only on the newest batch can narrow what the model sees. Replay and rehearsal provide continuity, but they also influence which errors and habits persist. Their value must be checked against held-out positions and match results.

05 / BUGS THAT LOOK PLAUSIBLE

A legal-looking move can hide an indexing error.

The current network permutes its policy tensor from channel-first order to square-first order before flattening. That detail connects the convolutional output to the action encoder. Flattening the wrong dimension order still produces 4,672 values, but assigns them to different moves.

A useful test starts with a known legal move, encodes its index, places a score at the corresponding policy location, then decodes the selected result. Sliding moves, knight moves, castling, and promotions all need coverage.

Whose value is it?

The side to move changes after a move. A favorable position for a child can be unfavorable for its parent, so search must apply the correct sign when values cross that boundary. A sign bug can run quickly, generate games, and train on its own mistakes.

Parallel search needs cleanup

When several searches are in flight, paths are temporarily reserved to encourage useful parallel work. Reservations must be removed when evaluations return. Board apply/undo operations must also restore the exact state. The repository’s smoke tests explicitly check these boundaries and visit accounting.

06 / EARNING A PROMOTION

Finishing a training job is not a win.

A candidate faces the current champion in an arena with paired colors. Wins, losses, and draws determine whether the candidate is promoted. Lower training loss alone does not justify replacing the champion.

The supplied arena configuration uses 40 games and a 55% promotion threshold, and explicitly labels that game count as suitable for plumbing tests. A meaningful strength claim needs a larger evaluation, consistent search budgets, and uncertainty estimates. Small match sets can swing on a handful of results.

The next useful result

First establish a correct, repeatable loop. Then measure whether successive candidates actually improve under fixed conditions. The interesting question is not just whether the bot can play a game—it is whether the training process reliably teaches it to play a better one.