# AlphaZero: Only the Rules, Self-Play from Scratch, Mastering Chess, Shogi and Go

> AlphaZero used one algorithm and one set of hyperparameters, given only the rules, to learn chess, shogi and Go from random play via self-play with a neural network and Monte Carlo tree search (MCTS), and beat each world-champion program. This post checks shapes, match statistics and search volume.

- URL: https://dmxsf.com/en/blog/alphazero-mastering-chess-and-shogi-by-self-play/
- [DMXSF](https://dmxsf.com/en/about/)
- Published: 2017-12-15
- Updated: 2026-11-11
- Paper notes
- Paper: [Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm](https://arxiv.org/abs/1712.01815) (David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, et al. · arXiv preprint, 2017)

## Why this paper matters

Before AlphaZero, the strongest chess programs relied on decades of handcrafted evaluation functions and heavily optimized alpha-beta search, and shogi programs followed the same recipe. AlphaGo Zero had already shown that Go can be learned from self-play alone, but Go is translation invariant, rotation and reflection symmetric, and has only win or loss outcomes. Chess and shogi have none of these conveniences: the rules are asymmetric, pieces interact over long ranges, and games can be drawn.

This paper (Silver et al., DeepMind, posted in December 2017 and later published in Science) generalizes AlphaGo Zero into AlphaZero, which trains all three games with **the same algorithm, the same network architecture and the same hyperparameters**, adjusting only the size of the exploration noise per game. It is the textbook example of "search plus learning": the model provides intuition for the search, and the search turns that intuition into a better training target. Read next to the [Reasoning RL](https://dmxsf.com/en/wiki/post-training/reasoning-rl/) page of this site, it shares one idea with it: improving a policy again and again from a verifiable outcome signal.

## Core idea: the network guides the search, the search sets the exam

The network $(p, v)=f_\theta(s)$ takes a board position $s$ and outputs prior probabilities $p$ over moves and an estimate $v\approx\mathbb{E}[z\mid s]$ of the outcome. At each move AlphaZero runs MCTS: every simulation starts at the root, picks at each node a move with a low visit count, a high prior and a high value, walks down to a leaf, evaluates the leaf with the network and backs the value up. The distribution $\pi$ over root moves (by visit counts) after the search is stronger than the raw $p$. In self-play both sides move according to $\pi$. At the end the outcome $z$ ($-1$ for a loss, $0$ for a draw, $+1$ for a win) is known, and the network is trained toward $\pi$ and $z$:

$$
l = (z-v)^2 - \pi^{\top}\log p + c\,\lVert\theta\rVert^2
$$

The three terms are the mean-squared error of the value, the cross-entropy of the policy, and L2 weight regularization. The updated network is used for the next round of self-play, closing the loop: **search produces a policy better than the network, the network learns it, and the next search starts from a stronger prior.**

## Method details

- **Input.** A position is encoded as an $N\times N\times(MT+L)$ stack of planes: piece positions and repetition counts for the last $T=8$ steps, plus constant planes such as colour, total move count, castling rights (chess) and the no-progress count.
- **Output.** The chess policy is an $8\times8\times73$ stack of planes, 4,672 possible moves. Shogi uses $9\times9\times139$, 11,259 moves. Go is the same as AlphaGo Zero, $19\times19+1$ stone placements plus a pass. Illegal moves are masked to probability zero and the rest renormalized.
- **Search and training configuration.** Each training search uses 800 simulations. The learning rate starts at 0.2 and is dropped three times (to 0.02, 0.002, 0.0002). Moves are chosen in proportion to the root visit counts. Dirichlet noise is added to the prior at the root for exploration, scaled in inverse proportion to the typical number of legal moves, with $\alpha$ equal to 0.3, 0.15 and 0.03 for chess, shogi and Go.
- **Scale.** 700,000 training steps with batch size 4,096 from random parameters, 5,000 first-generation TPUs generating self-play games and 64 second-generation TPUs training the network.

## Experiments and findings

Training progress is measured in Elo. In chess AlphaZero passes Stockfish after about 4 hours (300k steps), in shogi it passes Elmo after under 2 hours (110k steps), and in Go it passes AlphaGo Lee after 8 hours (165k steps). After training the paper plays 100-game matches against each baseline with 1 minute per move (50 games as White and 50 as Black). Results (Table 1, from AlphaZero's perspective):

| Opponent | AlphaZero as White (W/D/L) | AlphaZero as Black (W/D/L) | Total |
| --- | --- | --- | --- |
| Stockfish (chess) | 25 / 25 / 0 | 3 / 47 / 0 | 28 / 72 / 0 |
| Elmo (shogi) | 43 / 2 / 5 | 47 / 0 / 3 | 90 / 2 / 8 |
| AlphaGo Zero 3-day (Go) | 31 / 0 / 19 | 29 / 0 / 21 | 60 / 0 / 40 |

On search efficiency, AlphaZero evaluates about 80 thousand positions per second in chess and 40 thousand in shogi, against 70 million for Stockfish and 35 million for Elmo, yet its MCTS scales better with thinking time. The paper also checks common human openings, which AlphaZero independently discovers and plays frequently during self-play.

## Checking it with code

The code below does three things. (1) It computes the number of input planes and the action-space sizes from the structure in Tables S1 and S2 of the appendix. (2) It converts the Table 1 results into scores, Elo gaps and 95% confidence intervals (using the variance of the per-game score, a draw counting as half). (3) It computes a few ratios from the search speeds and training statistics the paper gives.

```python
import math

# ---- 1) Input and output shapes (Tables S1 and S2 of the paper) ----
games = {  # (planes per history step M, constant planes L)
    "Go": (2, 1),  # own stones, opponent stones; colour
    "Chess": (6 + 6 + 2, 1 + 1 + 2 + 2 + 1),  # pieces, repeats; colour...
    "Shogi": (14 + 14 + 7 + 7 + 3, 1 + 1),  # + prisoners; colour, moves
}
for name, (m, l) in games.items():
    print(f"{name:5s} input planes = 8 x {m} + {l} = {8 * m + l}")
print("chess policy:", 8 * 8 * 73, " shogi policy:", 9 * 9 * 139,
      " go policy:", 19 * 19 + 1)

# ---- 2) Table 1 matches: score, Elo gap and 95% confidence interval ----
elo = lambda s: 400 * math.log10(s / (1 - s))
# (win, draw, loss) for AlphaZero; 50 games as White plus 50 as Black
matches = {
    "chess vs Stockfish": (25 + 3, 25 + 47, 0 + 0),
    "shogi vs Elmo": (43 + 47, 2 + 0, 5 + 3),
    "go vs AG0 3-day": (31 + 29, 0, 19 + 21),
}
for name, (w, d, l) in matches.items():
    n = w + d + l
    score = (w + 0.5 * d) / n
    var = (w * (1 - score) ** 2 + d * (0.5 - score) ** 2
           + l * score ** 2) / n  # variance of the score of one game
    se = math.sqrt(var / n)
    lo, hi = score - 1.96 * se, score + 1.96 * se
    print(f"{name:19s} {w}-{d}-{l} score {score:.1%} elo {elo(score):+6.1f}"
          f" 95% CI [{elo(lo):+6.1f}, {elo(hi):+6.1f}]")

# ---- 3) Search and training volume ----
print("positions/s: chess", 70_000_000 // 80_000, "x, shogi",
      35_000_000 // 40_000, "x fewer for AlphaZero")
for name, hours, millions in [("chess", 9, 44), ("shogi", 12, 24),
                              ("go", 34, 21)]:
    print(f"{name}: {millions}M games in {hours} h = "
          f"{millions * 1e6 / (hours * 3600):.0f} games/s")
```

Output (standard library only, finishes instantly):

```text
Go    input planes = 8 x 2 + 1 = 17
Chess input planes = 8 x 14 + 7 = 119
Shogi input planes = 8 x 45 + 2 = 362
chess policy: 4672  shogi policy: 11259  go policy: 362
chess vs Stockfish  28-72-0 score 64.0% elo +100.0 95% CI [ +67.5, +134.1]
shogi vs Elmo       90-2-8 score 91.0% elo +401.9 95% CI [+309.1, +572.9]
go vs AG0 3-day     60-0-40 score 60.0% elo  +70.4 95% CI [  +2.8, +143.9]
positions/s: chess 875 x, shogi 875 x fewer for AlphaZero
chess: 44M games in 9 h = 1358 games/s
shogi: 24M games in 12 h = 556 games/s
go: 21M games in 34 h = 172 games/s
```

How to read these numbers:

1. **The plane counts match the paper's tables.** 17 for Go, 119 for chess and 362 for shogi agree with the totals of Table S1, and the action spaces of 4,672 and 11,259 agree with the text.
2. **The chess Elo gap is about 100 points, with a wide interval.** 28 wins and 72 draws in 100 games give a score of 64%, which is +100 points, with a 95% interval of about +68 to +134. Many draws compress the Elo scale (the paper's footnote says so too), so 100 points cannot be compared directly with shogi's +402.
3. **The Go edge over AlphaGo Zero's 3-day version is only barely significant.** 60 to 40 converts to +70 points with a lower bound of just +2.8, and 100 games cannot support finer conclusions.
4. **The search volume differs by a factor of 875.** Both ratios come out as 875, a coincidence of two integer divisions, and show that the network prior compresses the search by almost three orders of magnitude. In the training statistics, chess produced 44 million games in 9 hours, about 1,358 games per second, the output of 5,000 TPUs that ordinary hardware cannot reproduce.

## Limitations and what to keep in mind

- **A very high compute bar and no code.** 5,000 first-generation TPUs plus 64 second-generation TPUs, and the paper ships no code. The "24 hours" is wall-clock time, not cost.
- **The match conditions are not equal.** AlphaZero used 4 TPUs while Stockfish and Elmo used 64 CPU threads and a 1 GB hash, and with 1 minute per move the hardware of the two kinds of program is hard to compare.
- **It needs a perfect rules simulator.** The search relies on exact state transitions and terminal detection. Real tasks have no such simulator, which is the main obstacle to carrying the method over to language models or robots, and the problem that later world-model work, which learns an environment model to replace the simulator, sets out to solve.
- **Symmetry and draws.** Go has only win or loss, while chess and shogi have many draws, so Elo gaps of different games in the paper cannot be compared directly.
- **Only three board games.** Perfect information, two players, zero sum and fixed rules, none of which the paper relaxes.

## What to take from this paper

1. **Search is a policy-improvement operator.** MCTS turns the network's prior into a stronger visit distribution, the network learns that distribution, and the loop repeats.
2. **Generality comes from removing human knowledge.** Apart from the rules there is no domain knowledge, and one set of hyperparameters works across three games.
3. **Keep a single network.** There is no gating of the "new network must win 55%" kind, and continual updates are simpler.
4. **Report results with error bars.** A 100-game match converted to Elo has a wide interval, especially the Go result.
5. **The rules simulator is the key assumption.** Planning in this way needs an environment that can be rolled forward exactly.

## Further reading

- Paper: [Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm](https://arxiv.org/abs/1712.01815)
- Related Wiki on this site: [Reasoning RL](https://dmxsf.com/en/wiki/post-training/reasoning-rl/)
- Glossary: [AlphaZero](https://dmxsf.com/en/glossary/#alphazero), [Monte Carlo tree search](https://dmxsf.com/en/glossary/#mcts)

## FAQ

### How does AlphaZero differ from AlphaGo Zero?

AlphaZero is the generalized version of AlphaGo Zero. The paper lists the differences. It optimizes the expected outcome (so draws are handled) instead of the win probability. It no longer augments data with the rotations and reflections of Go. It no longer gates a new network on beating the best one by a 55% margin and instead maintains a single, continually updated network. It does not tune search hyperparameters per game and only scales the exploration noise to the typical number of legal moves.

### Does AlphaZero need human game records?

No. Apart from the rules there is no domain knowledge. The rules are used to simulate positions during search, to detect the end of a game and to encode the input and output planes. Training in the paper starts from random play and uses only data generated by self-play.

### Why does AlphaZero use MCTS rather than the alpha-beta search of chess engines?

The paper's argument is that a neural network's position evaluations carry approximation errors. MCTS averages the evaluations in a subtree, so the errors tend to cancel, while alpha-beta computes a minimax and propagates the largest error in the subtree to the root. AlphaZero searches about 80 thousand positions per second against roughly 70 million for Stockfish, but the network lets it focus on the most promising lines.

### How reliable is AlphaZero's result against Stockfish in the paper?

The 100-game result is 28 wins, 72 draws and 0 losses, a score of 64%, which converts to about 100 Elo points with a 95% interval of roughly 68 to 134, clearly above zero. Note the match conditions. Each side had 1 minute per move, AlphaZero used 4 TPUs and Stockfish used 64 CPU threads with a 1 GB hash, so the hardware is not equal.
