# The atlas of chess and blind systems

Part of [`research/chess-proof`](../README.md). Scripts are in the parent folder, results in `../data/`, figures in `../figures/`.

## A bird's-eye view of chess: the atlas

`atlas_perft.py`, `atlas_openings.py` and `atlas_report.py` gather what can be derived about chess as a whole: its size,
its geometry, the value of a move, the opening tree to three plies, and the flaws in it. They write `atlas.json` and
`chess_atlas.png`. Everything below is derived here, apart from the two cited sizes. Opening scores come from
Stockfish 16, so they are engine judgements, not proofs.

![The atlas](../figures/chess_atlas.png)

**Size.** Perft from the start, with its components, matches the published values to depth 6:

| plies | sequences | captures | en passant | checks | checkmates |
|---|---|---|---|---|---|
| 1 | 20 | 0 | 0 | 0 | 0 |
| 2 | 400 | 0 | 0 | 0 | 0 |
| 3 | 8 902 | 34 | 0 | 12 | 0 |
| 4 | 197 281 | 1 576 | 0 | 469 | 8 |
| 5 | 4 865 609 | 82 719 | 258 | 27 351 | 347 |
| 6 | 119 060 324 | 2 812 008 | 5 248 | 809 099 | 10 828 |

The fastest checkmates take 4 plies, and there are exactly 8, all versions of the Fool's Mate: f3 or f4 with g4,
then ...Qh4#. All 347 mates at ply 5 are their mirror images against Black: 281 are Qh5#, the rest Qg6 or Qh5 mates
with the queen or a bishop. Chess has about 4.8 × 10⁴⁴ legal positions (Tromp) and about 10¹²⁰ games (Shannon).

**Geometry** (squares reached from each square of an empty board). Knight 2–8, mean
5.25. Bishop 7–13, mean 8.75. Rook always
14. Queen 21–27, mean 22.75. King
3–8, mean 6.5625. Knights lose half their reach on the rim, and
bishops nearly half; a rook's reach never changes.

**The value of a move.** Stockfish 16 at depth 22 gives the start +0.38 with White to
move and -0.37 with Black to move. One tempo is worth 0.75 pawns,
and White's starting edge is exactly half of it. The pieces' values where they stand are measured in the occlusion
section of [03-stockfish-probes.md](03-stockfish-probes.md).

**The opening tree.** All 20 first moves (depth 22), all 400 replies (depth 20) and all 8 902 positions after three
plies (depth 16), each from one multi-PV search. The tree is consistent: each first move's depth-22 score and the best
of its depth-20 replies differ by 3.5 centipawns on the median and
20 at most.

First moves, in pawns for White: e4 +0.38 · d4 +0.35 · Nf3 +0.32 · g3 +0.21 · c4 +0.21 · c3 +0.16 · e3 +0.15 · Nc3 +0.00 · a3 -0.05 · d3 -0.06 · b3 -0.07 · h3 -0.13 · a4 -0.14 · f4 -0.28 · b4 -0.34 · h4 -0.42 · Nh3 -0.65 · f3 -0.72 · Na3 -0.73 · g4 -1.19.

How many moves are good? The figures are means per position:

| move | legal | within 1 pawn of the best | within 0.5 | within 0.25 |
|---|---|---|---|---|
| White's first | 20 | 16.0 | 11.0 | 7.0 |
| Black's first | 20 | 17.4 | 11.8 | 6.35 |
| White's second | 22.25 | 16.91 | 9.29 | 4.29 |

The legal choices grow, but the good ones shrink: within a quarter pawn of the best, 7, then 6.4, then 4.3 moves.
This is the opening's funnel, and it is why theory exists.

**Named openings** (Stockfish 16, depth 22, after the defining moves, in pawns for White):

| opening | moves | score |
|---|---|---|
| Latvian Gambit | e4 e5 Nf3 f5 | +1.48 |
| Englund Gambit | d4 e5 | +1.17 |
| Alekhine's Defence | e4 Nf6 | +0.83 |
| Scandinavian Defence | e4 d5 | +0.73 |
| Pirc Defence | e4 d6 d4 Nf6 Nc3 g6 | +0.65 |
| Dutch Defence | d4 f5 | +0.65 |
| Budapest Gambit | d4 Nf6 c4 e5 | +0.56 |
| King's Indian Defence | d4 Nf6 c4 g6 Nc3 Bg7 | +0.54 |
| Petrov Defence | e4 e5 Nf3 Nf6 | +0.47 |
| Sicilian Defence | e4 c5 | +0.42 |
| French Defence | e4 e6 | +0.40 |
| Sicilian Najdorf | e4 c5 Nf3 d6 d4 cxd4 Nxd4 Nf6 Nc3 a6 | +0.36 |
| Caro-Kann Defence | e4 c6 | +0.35 |
| Slav Defence | d4 d5 c4 c6 | +0.31 |
| Ruy Lopez | e4 e5 Nf3 Nc6 Bb5 | +0.30 |
| Queen's Gambit Accepted | d4 d5 c4 dxc4 | +0.28 |
| Queen's Gambit Declined | d4 d5 c4 e6 | +0.26 |
| Nimzo-Indian Defence | d4 Nf6 c4 e6 Nc3 Bb4 | +0.23 |
| English Opening | c4 | +0.21 |
| Italian Game | e4 e5 Nf3 Nc6 Bc4 | +0.17 |
| London System | d4 d5 Bf4 | +0.14 |
| Scotch Game | e4 e5 Nf3 Nc6 d4 | +0.11 |
| Réti Opening | Nf3 d5 c4 | -0.04 |
| King's Gambit | e4 e5 f4 | -0.45 |
| Grob Opening | g4 | -1.06 |

The classical main lines sit in a narrow band of +0.1 to +0.4: Ruy Lopez, Italian, Scotch, Queen's Gambit, Slav,
Nimzo-Indian, Caro-Kann, French, Sicilian and Najdorf. The sharper defences give White a little more, +0.65 to +0.83:
Pirc, Dutch, Scandinavian and Alekhine. The gambits that weaken the king's side are the outliers. The Latvian
(...f5, +1.48) and the Englund (...e5, +1.17) are bad for Black. The King's Gambit (f4, −0.45) and the Grob (g4,
−1.06) are bad for White.

**Black's answers to each first move** (depth 20). The score is after Black's best reply, in pawns for White:

| first move | best reply | score | replies within 0.25 | which |
|---|---|---|---|---|
| 1.e4 | ...e5 | +0.27 | 5 | e5, c5, e6, c6, Nc6 |
| 1.d4 | ...Nf6 | +0.29 | 5 | Nf6, c6, d5, e6, d6 |
| 1.Nf3 | ...d5 | +0.31 | 10 | d5, Nf6, e6, c6, c5, g6, h6, f5, b6, d6 |
| 1.g3 | ...e5 | +0.17 | 13 | e5, d5, c5, g6, Nf6, c6, e6, d6, Nc6, a5, h5, h6, a6 |
| 1.c4 | ...e5 | +0.20 | 8 | e5, c5, Nf6, e6, g6, d6, c6, Nc6 |
| 1.c3 | ...d5 | +0.14 | 12 | d5, Nc6, Nf6, e6, c6, e5, b6, d6, c5, f5, h6, g6 |
| 1.e3 | ...d5 | +0.14 | 12 | d5, Nf6, e6, b6, a6, g6, e5, c5, c6, d6, h6, a5 |
| 1.Nc3 | ...d5 | +0.00 | 4 | d5, Nf6, e5, Nc6 |
| 1.a3 | ...c5 | -0.15 | 6 | c5, e5, g6, Nf6, d5, e6 |
| 1.d3 | ...d5 | -0.12 | 10 | d5, Nf6, c5, e5, e6, Nc6, g6, d6, a6, a5 |
| 1.b3 | ...e5 | -0.10 | 8 | e5, d5, c6, Nf6, c5, e6, d6, a6 |
| 1.h3 | ...e5 | -0.13 | 3 | e5, d5, Nf6 |
| 1.a4 | ...e5 | -0.18 | 7 | e5, d5, Nf6, e6, Nc6, a6, c6 |
| 1.f4 | ...Nf6 | -0.29 | 3 | Nf6, d5, g6 |
| 1.b4 | ...e5 | -0.29 | 5 | e5, d5, Nf6, e6, c6 |
| 1.h4 | ...d5 | -0.45 | 5 | d5, e5, c5, Nf6, e6 |
| 1.Nh3 | ...d5 | -0.60 | 4 | d5, e5, Nf6, Nc6 |
| 1.f3 | ...e5 | -0.78 | 2 | e5, d5 |
| 1.Na3 | ...e5 | -0.53 | 4 | e5, Nf6, e6, d5 |
| 1.g4 | ...d5 | -1.18 | 1 | d5 |

The engine rediscovers the main defences of opening theory. Against 1.e4 the replies within a quarter pawn are ...e5,
...c5, ...e6, ...c6 and ...Nc6: the Open Games, the Sicilian, the French, the Caro-Kann and the Nimzowitsch Defence.
Against 1.d4 they are ...Nf6, ...c6, ...d5, ...e6 and ...d6: the Indian defences, the Slav and the Queen's Gambit
set-ups. How many good replies Black has follows White's move in both directions. The strongest first moves leave Black
about five. Quiet ones (1.Nf3, 1.g3, 1.c3, 1.e3) leave 10–13. The worst again leave few, because punishing them takes
precision: against 1.g4, only ...d5 is within a quarter pawn.

**Flaws.**

- Four first moves lose a pawn or more against the best: g4 (−1.57), Na3 (−1.11), f3 (−1.10) and Nh3 (−1.03).
- 53 of the 400 first replies do the same. The worst is 1.h4 g5 (−2.47).
- 329 of the 8 902 second moves by White lose two pawns or more, and 16 allow a forced mate.
- In 7 of the 400 positions, the seven-fact rule's favourite move is itself a blunder of 1.5 pawns or more, mostly an
  early Nh3 after f3 or f4. The rule knows material, not king safety, and this is where that shows.

**The pattern: the f- and g-pawns.** One structural fact runs through the size, the flaws and the theory. The king's
diagonals, e1–h4 and e8–h5, are guarded at the start only by the f- and g-pawns.

- Every fastest mate (all 8 at ply 4, all 347 at ply 5) runs down one of those diagonals or onto g6.
- f- and g-pawn moves are 17–20% of all moves, but 50% of the flawed first moves, 58% of the flawed replies and 32%
  of the flawed second moves.
- Every one of the 16 second moves that allow a forced mate comes after White has moved the f-pawn.
- The dubious gambits are f- and g-pawn moves: King's Gambit f4, Latvian ...f5, Grob g4.

Opening theory, seen from above, is largely the art of not moving those two pawns too early.

### The fourth ply, sound theory and transpositions

`atlas_ply4.py` scores every move in all 8 902 positions after three plies: 197 281 positions at depth 12. Each
depth-16 score at ply 3 agrees with the best of its depth-12 replies within 8 centipawns on the
median and 20 for 90% of positions. `atlas_report4.py` derives:

| ply | legal moves | within 0.25 of best | within 0.5 | lose 2+ pawns | allow mate | f/g-pawn moves: share of moves → of those flaws | good moves (within 0.25) by pawn / knight / bishop |
|---|---|---|---|---|---|---|---|
| 1 | 20.0 | 7.0 | 11.0 | 0 | 0 | 20% → 0% | 86% / 14% / 0% |
| 2 | 20.0 | 6.35 | 11.8 | 2 | 0 | 20% → 100% | 80% / 20% / 0% |
| 3 | 22.25 | 4.29 | 9.29 | 329 | 16 | 17% → 32% | 73% / 21% / 6% |
| 4 | 22.16 | 3.85 | 7.98 | 16 763 | 1 143 | 17% → 28% | 72% / 22% / 6% |

**The size of sound opening theory.** Count the move sequences in which every move is within a margin of the best at
its turn. Within 0.25 pawns: 7 → 65 → 343 → 2 143
sequences over plies 1–4, about 6.8 sound moves per ply. Within 0.5:
11 → 147 → 1 691 → 19 463, about
11.81 per ply. All legal sequences grow about 21-fold per ply (20 → 400 →
8 902 → 197 281). After four plies, sound play at a quarter-pawn tolerance is about 1% of the tree. Its branching factor
of about 7 is what makes opening theory learnable, and its growth is why theory never ends.

**What sound early play is made of.** Good moves are pawn moves (72–86%) and knight moves (14–22%). Bishops make 6%,
the queen under 1%, and rooks almost never.

**The f/g-pawn pattern holds one ply deeper.** At ply 4, f- and g-pawn moves are 17% of Black's second moves but 28% of
the 16 763 that lose two pawns or more. 1 143 second moves by Black allow a forced mate.

**Transpositions** (`atlas_unique.py`; distinct positions by board, side to move, castling rights and capturable
en-passant square). The counts match the published sequence (OEIS A083276):

| ply | move sequences | distinct positions | sequences per position |
|---|---|---|---|
| 1 | 20 | 20 | 1.0 |
| 2 | 400 | 400 | 1.0 |
| 3 | 8 902 | 5 362 | 1.7 |
| 4 | 197 281 | 72 078 | 2.7 |
| 5 | 4 865 609 | 822 518 | 5.9 |

From ply 3 on, different move orders converge on the same positions, and ever faster. This is why opening theory is
organized by position, not by move order.

## Ignoring Black: how long can White play a fixed system blind?

`blind_system.py` asks a precise form of the question: how many moves of a fixed White sequence can be played without
looking at Black, and does such a system restrict Black? Forty Black opponents each play a sound but varied game:
Stockfish 16 at depth 10, choosing at random among moves within 0.3 pawns of the best. After every Black move, every
White move is scored at depth 12. A system move breaks in a game if it is illegal there or loses a pawn or more against
the best move. After a break, White plays the best move and returns to the system where it can. Before each Black
move, every Black move is scored too: the good ones are within half a pawn of the best, and the pitfalls lose a pawn or
more. The computed system takes, at every step, the move whose worst loss over all forty games is smallest.

| system | moves | blind moves with no break in any game | breaks in the first 7 moves (of 280) | White's mean score after move 7 | Black's good moves after moves 1–4 |
|---|---|---|---|---|---|
| Most blind-safe (computed) | e2e4 g1f3 b1c3 | 3 | 0 | +0.38 | 13 → 8 → 9 |
| London System | d2d4 c1f4 e2e3 g1f3 c2c3 f1d3 b1d2 h2h3 e1g1 d1e2 | 1 | 39 | -0.55 | 7 → 11 → 12 → 11 |
| Colle System | d2d4 g1f3 e2e3 f1d3 c2c3 b1d2 e1g1 f1e1 d1e2 e3e4 | 3 | 44 | -0.80 | 7 → 10 → 9 → 10 |
| Stonewall Attack | d2d4 e2e3 f1d3 f2f4 g1f3 c2c3 e1g1 b1d2 d1e1 f3e5 | 2 | 26 | -0.24 | 7 → 14 → 10 → 13 |
| King's Indian Attack | g1f3 g2g3 f1g2 e1g1 d2d3 b1d2 e2e4 f1e1 c2c3 a2a4 | 4 | 8 | +0.25 | 10 → 14 → 14 → 12 |
| Hippopotamus | g2g3 f1g2 b2b3 c1b2 d2d3 e2e3 b1d2 g1e2 h2h3 a2a3 | 3 | 15 | -0.47 | 12 → 14 → 12 → 7 |
| Double fianchetto | g1f3 g2g3 f1g2 b2b3 c1b2 e1g1 d2d3 b1d2 e2e4 f1e1 | 3 | 29 | +0.10 | 10 → 14 → 14 → 12 |

**The longest blind system is the King's Indian Attack.** 1.Nf3 2.g3 3.Bg2 4.O-O is safe in all forty games. 5.d3,
6.Nbd2 and 7.e4 stay safe in 38, 38 and 36 of them, with White's mean score between +0.2 and +0.44. The eighth move,
Re1, breaks in 12 games and the mean drops to −0.85.

**The most blind-safe sequence is only three moves long:** 1.e4 2.Nf3 3.Nc3. After that no fourth move is safe in
every game; the least bad one loses almost two pawns somewhere. Played blind, the human systems break sooner. The London
breaks at move two: 2.Bf4 is a mistake in 14 of the 40 games. The Stonewall lasts two moves, and the Colle, the
Hippopotamus and the double fianchetto three. By move ten every one of them leaves White worse on average.

**Quiet systems do not restrict Black; they free it.** After the King's Indian Attack's first moves Black has 10–14
good moves; after the active 1.e4 and 2.Nf3, about 8. Pitfalls for Black grow in every opening as the pieces meet,
from 3 at move one to about 20 by move ten. A defensive system does not specially create them.

Limits: the opponents play sound moves at random, not against the system; an opponent who knows the system can aim at
its weak points, and would break it sooner. The scores are Stockfish at depths 10–12.
