Hazel reports · ^report(61) · Hazel’s search · 2026-11-21, revised 2026-11-21 12:31 MST · work in progress · after ^report(60)
Does Hazel Repeat Itself? Checkers, Six Moves Ahead
Matthew asked (^ticket(811)): when Hazel plays Checkers against itself, each side looking six moves ahead for the whole game, how much of the work is repeated, across the two players and across all their moves? His guess: a great many of the “sub-worlds” searched are shared, between the players and as the game goes on; and since Hazel playing itself has nothing to hide from itself, two players sharing what they have searched should explore faster than two keeping it private. Counted here, position by position, over 3 whole games (503 moves).
The 69% is how much of the search repeats, not how much a memo table would save. With a table each player keeps, the search looks at 52% fewer positions (4,755,402 down to 2,283,980), and a move takes 37% less time; why less than 69%.
Every count here is exact: each position the search looks at, from the Checkers rules’ own search, mirrored in JavaScript and checked against the compiled Hazel move for move (how). The times are one run each on a laptop, and only compare the ways with each other.
Outline#
- How Hazel looks ahead: the search in the Checkers rules, and what counts as the same position.
- Two thirds of the search is a repeat: where the repeats are, within a move, across a player’s moves, across the players.
- The two players never meet: why a position never comes up in both players’ searches with as far still to look.
- By position alone, the players share a little: what overlaps if how far there is still to look is let go.
- What a memo table would save: one for each move, one each player keeps, one shared; and tables that let a deeper search answer for a shallower one.
- The guess, confirmed and rejected: what is shared, and what sharing would buy.
- What next, and how this was put together.
How Hazel looks ahead#
Hazel’s opponent searches every move six moves deep (three of its own, three of yours), by negamax with alpha-beta, and keeps nothing from one search to the next. In checkers/rules/Checkers.hz, choose tries each of its moves (pick) with the whole window, so the value of each move is exact; below that, walk tries replies in order and stops a branch as soon as it cannot change the answer (alpha-beta). At the edge, six moves on, a position is valued by its pieces (value: a man 100 and 2 a row advanced, a king 160). There is no table of positions searched: each move’s search starts afresh, and so does each player’s.
A position is the pieces (black’s, white’s, which are kings) and whose turn it is. The search’s answer for a position depends also on how far there is still to look: the same position four moves from the edge and two moves from it are different questions. So a repeat, here, is a position looked at again with as far still to look, the one kind whose answer could simply be reused.
Two thirds of the search is a repeat#
Of 4,756,771 positions looked at in 3 games, 69% had been looked at before with as far still to look: 63% in the same move’s search, 5.9% in the same player’s earlier moves, and 0.0% only in the other player’s. Nearly all the repetition is inside one search: the same moves played in another order lead to the same position (a transposition), and the search walks into it again. Across a player’s own moves a little comes back too, mostly in the endgame, where kings shuffle and positions recur. Across the two players, none at all; the next section says why.
Most of what is looked at is the edge: 3,529,144 (74%) only valued, six moves on, and those repeat the most. The deeper in the tree, the more often a position comes back:
| moves still to look | looked at | looked at before |
|---|---|---|
| 5 | 3,617 | 5% |
| 4 | 22,289 | 9% |
| 3 | 67,799 | 28% |
| 2 | 276,428 | 44% |
| 1 | 857,494 | 60% |
| 0 | 3,529,144 | 75% |
The two players never meet#
A position comes up in both players’ searches, but never with as far still to look: in black’s searches, black is to move with 6, 4, 2 or 0 moves still to look; in white’s, with 5, 3 or 1. Each search starts with its own player to move and six to look, and every move changes both whose turn it is and how far is left, together. So the depth at which black’s turn comes is always even in black’s search and odd in white’s. A table of exact answers, kept by position and depth, can never hand one player’s answer to the other.
By position alone, the players share a little#
Letting go of how far there is still to look, 77% of the positions looked at had been looked at before: 64% in the same search, 7.2% in the same player’s earlier moves, and 6.3% only by the other player. That 6.3% is the most the two players could ever share, and only by letting one player’s answer from a different depth stand for the other’s: a deeper answer for a shallower question is a better answer, but it is no longer the answer Hazel’s own search would give, so the moves chosen can change. In all, 1,089,630 different positions came up, with any look-ahead.
What a memo table would save#
A table of the positions searched, kept by each player from move to move, would make a move take 37% less time (17.3 ms to 10.9 ms here), with every move chosen exactly as now; a table shared by both players saves nothing more. A table that lives only for one move’s search already saves 31% (11.9 ms): that is the repetition within a search. Kept across the player’s moves it saves a little more. Shared between the players it changes nothing: the same positions are searched (the parity again), at the same cost; the table only gets bigger (354,202 entries at most, against 185,321).
| table | searched past the edge | valued at the edge | table answers | ms a move | moves chosen differently | table size, most |
|---|---|---|---|---|---|---|
| none (Hazel now) | 1,226,258 | 3,529,144 | 0 | 17.3 | 0 of 503 | 0 |
| a table each move, cleared after it | 922,403 | 1,720,634 | 234,571 | 11.9 | 0 of 503 | 6,724 |
| each player's own, kept move to move | 826,720 | 1,457,260 | 221,296 | 10.9 | 0 of 503 | 185,321 |
| one table both players share | 826,720 | 1,457,260 | 221,296 | 10.9 | 0 of 503 | 354,202 |
| each player's own, deeper answers allowed | 812,722 | 1,423,218 | 216,937 | 10.3 | 4 of 503 | 171,081 |
| one shared, deeper answers allowed | 818,422 | 1,459,786 | 213,481 | 10.5 | 14 of 503 | 269,028 |
Why a table saves less than the 69% that repeats: of the 3,293,144 repeats, it takes away 75%; the rest it cannot answer for, and what it does answer costs time of its own. Positions at the edge are valued, not looked up (looking one up would cost more than valuing it), so a repeat there goes only when the table answers for the position above it: 562,487 of them are still valued. And alpha-beta leaves most positions with only a bound on their value, since it stops as soon as it knows a position cannot change the answer; a bound answers a later question only when it settles that question, so about 258,000 positions are searched again. The table answered 221,296 times. Making a key for each position and keeping the table then turn 52% fewer positions into 37% less time.
Letting a deeper search answer for a shallower one, as chess programs’ tables do, saves a little more for each player’s own table (10.3 ms), and changes 4 of 503 moves. Sharing that kind of table between the players does not help: 10.5 ms, and 14 moves chosen differently. What one player found deeper is mostly what the other would have found anyway, a move later; but positions the other player searched at its own depths crowd the table and its answers, without lessening the work.
The guess, confirmed and rejected#
Confirmed: most of Hazel’s Checkers search is repeated, about two thirds of it. Rejected: the repeats are not between the players, and sharing the search between them would not explore faster. The “sub-worlds” that come back are the ones a single search walks into twice, by different move orders, and to a smaller degree the ones a player meets again as the game goes on. A memo table pays for that, and pays most within each move’s search. The two players, looking the same distance ahead, ask about the same positions at opposite parities, so what one has found is never the answer to the other’s question, and the overlap that remains by position alone (6.3%) is too small, and too far from exact, to be worth sharing.
What next#
- A memo table in Hazel’s own search. The saving is a third of the time in the lab; in Hazel it comes with the cost of keeping the table (a persistent map keyed by the pieces, three numbers up to 2^32, and the depth) in a language with no hash tables. Worth measuring in the compiled rules before deciding.
- Better move order. Alpha-beta saves more when the best reply is tried first; the table’s best moves can order the next search. Not measured yet.
- Go. The same parity holds for any two-player search of fixed depth; Go’s positions transpose far more than Checkers’ do (captures aside, stones placed in any order), so the repetition within a search should be larger still.
How this was put together#
Build 1, the lab: tools/checkers-lab.mjs in hazeljs-examples (commit b3ec66c), the rules of checkers/rules/Checkers.hz mirrored step for step in JavaScript: the moves in the same order, the same values, the same alpha-beta walk and tie-break. node tools/checkers-lab.mjs check plays Hazel against itself and asks the compiled rules for the same move at every position: 403 positions of two games, every move and every list of legal moves the same. count watches every position the search looks at; share plays the games once with no table, then searches the same positions again in the same order with each kind of table. The tie-breaks come from a seeded stream (the page’s are random).
Build 2, the compiled rules (checked against only): checkers/compiled.js, the rules compiled by hazel-jit at hazelgrove/hazel d15466c7b1 (trial/794-games-aot). Times: one run each, Node 22.23 on a 13th-gen Intel i7-1370P laptop.
The data#
- The numbers, for programs too: every table in this report, and what its numbers measure, is also in this page as JSON, in its
<script type="application/json" id="report-data">element, so a reader or an agent that fetches the page alone has the dataset. The same, with any raw files that survive, is in061/data/.