TL;DR
AlphaZero plays a board game by combining two things: a neural network that suggests which moves look good and who is likely to win, and a tree search that checks those suggestions by looking ahead. It learns only from games it plays against itself, with no human games and no hand-written strategy. The search makes the network's move choices stronger than the raw network, and the network makes the search cheaper, so each improves the other.
Where you'll see it: in the self-play training recipe behind strong game programs for chess, shogi and Go.
Intuition
Think of a chess player who has two habits. The first is a gut feeling: looking at a position, they sense which moves are promising and how the game is likely to end. The second is calculation: they look a few moves ahead and test their gut feeling against what happens. Early on, the gut is poor and the calculation is short. Each game they play is a lesson. If calculation shows that a gut-favoured move was a mistake, the gut should be corrected. If calculation confirms a surprising move, the gut should be pushed toward it.
AlphaZero is this loop, automated. The gut feeling is a single neural network with two outputs. The calculation is a Monte Carlo tree search that uses the network to guide which lines to explore and to score the positions it reaches. Every move in every self-played game is decided by search, and the search result becomes the training target for the network. The network is then trained to predict both the search's choice and the eventual winner.
Why this design? Older game programs either searched with a hand-written evaluation (chess engines of the 2000s) or learned an evaluation from human games. Hand-written evaluations need expert effort for every new game. Learning from human games caps the strength at the level of the human games. AlphaZero asks only for the rules of the game and a way to measure who won.
flowchart LR N[Network: move priors p and value v] --> S[Tree search guided by p, scored by v] S --> M[Chosen move and visit counts pi] M --> G[Play self-play game to the end] G --> T[Training targets: pi and winner z] T --> U[Update network weights] U --> N
The math
Setting
The game is a sequence of positions . In each position the player to move chooses an action from the legal moves. The game ends with an outcome seen from the point of view of the player who was to move in position : for a win, for a draw, for a loss. The rules are the only domain knowledge the method needs.
The network takes a position and returns two things:
Here is a probability vector over legal moves (the policy head, with ), and is the predicted outcome for the player to move (the value head). The two heads share a trunk of convolutional layers with residual connections, which is why the network is a convolutional network at heart. The chess and shogi versions read the board as a stack of planes, one plane per piece type, so that the same local patterns can be detected anywhere on the board.
The search with the network inside
Each node in the search tree stores, for every legal action :
- a visit count , the number of simulations that took that action from ,
- a total value , the sum of the value estimates backed up through that action,
- the mean value ,
- the prior from the network, computed once when is first expanded.
Let be the total visits to . Selection at picks the action with the largest score
The first term favours actions that have worked well. The second term favours actions the network likes and that have been tried few times. The constant sets how much exploration matters. This is the same exploit-versus-explore trade-off as the UCT rule in Monte Carlo Tree Search, with the uniform bandit prior replaced by the network's policy.
When a simulation reaches a new leaf , the network evaluates it once, giving . That value is backed up along the path: each action on the path gains one visit and adds to , with the sign flipped at each step because the players alternate. Nothing is rolled out to the end of the game. The value head replaces the random playout used in plain MCTS.
After a fixed number of simulations at the root , the search outputs a policy from the visit counts:
The temperature controls how sharply moves are sampled from the visit counts. At moves are chosen in proportion to visits, which keeps self-play varied; as the most-visited move is played. (The arXiv paper states that moves are selected in proportion to root visit counts; annealing later in a game is the AlphaGo Zero practice and is an assumption here.) The vector is a better policy than alone, because it has been corrected by lookahead. That is the key idea: search turns the network's rough guess into a sharper target.
Training
Each self-play game produces, for every position visited, a training example . Here is the search policy at that move and is the final outcome seen from the player to move at . The network is trained on these examples with one loss:
Read it as three terms. The first pulls the value head toward the actual game result. The second, a cross-entropy, pulls the policy head toward the search's visit distribution. The third is weight decay with strength , which keeps the weights small. Both the value and the policy are supervised by the outcome of the search and the game, so no human labels are needed.
Note that the search generates the policy target, and the game outcome generates the value target. Neither depends on any human play.
Worked examples
At a node with 10 total visits, the root has three legal moves with these statistics. Use . This constant is chosen for the example, not a value from the paper.
| Move | Prior | Visits | Wins | |
|---|---|---|---|---|
| A | 0.5 | 6 | 3 | 0.500 |
| B | 0.3 | 3 | 2 | 0.667 |
| C | 0.2 | 1 | 0 | 0.000 |
- Compute .
- Move A: exploration term . Score .
- Move B: exploration term . Score .
- Move C: exploration term . Score .
- The largest score is B, so the next simulation goes through B.
Interpretation: B has the best record and a respectable prior, and it has few visits, so the search keeps probing it. C has the largest exploration bonus because it has the fewest visits, but its estimated value of 0 leaves it with the lowest score. A has the highest prior but is already well explored, so its bonus has shrunk.
After 100 simulations at a root, three legal moves have these visit counts: A = 60, B = 30, C = 10. The network's policy head gave priors and its value head predicted . The game was later won by the player to move, so . Use .
- The search policy is .
- Value error: .
- Policy cross-entropy: .
- Evaluate the logs: , , .
- The sum is , so the cross-entropy term is .
- Total loss for this example, before weight decay: .
Interpretation: the network put only 0.5 on move A, but the search put 0.6 there. The policy term is what moves the network toward the search's choice. The value term is large because the network was unsure () and the game was won, so the value head is pushed up for similar positions.
- prior 0.5
- prior 0.1
Tradeoffs and failure modes
| Situation | Problem | Better choice |
|---|---|---|
| Very large action space (for example Go with many legal points) | Visiting each child at least once is costly, so the prior matters a lot | Keep the prior strong and tune , or use progressive widening |
| Network is poor early in training | Search with a bad prior wastes simulations on bad moves | Keep the temperature high in early moves, and rely on many simulations per move |
| Stochastic games (dice, hidden information) | Plain tree search assumes known transitions, and the value target is noisy | Use methods designed for chance nodes or imperfect information instead |
| Game is small and solvable by brute force | A neural network adds cost without benefit | Exact search such as [[minimax-game |
| Environment has no simulator | Search needs to roll the state forward, and the rules are not available | Learn a model of the environment first, as in Model-Based Reinforcement Learning and MuZero |
| Self-play converges to a narrow style | The training data stops covering other positions | Add noise to the root priors during self-play, which the method already uses for exploration |
The method also depends heavily on compute. Each training move runs many network evaluations, so the cost is set by how many simulations are run per move, not only by the size of the network. Reported strength came from very large amounts of self-play, and a small reproduction usually gives a weaker player.
Another failure mode is that the search can only be as good as the network's values. If the value head systematically misjudges some kind of position, the search inherits that error and passes it into the training target. The loop corrects errors that show up in games, but it can take a long time to correct errors that the self-play never reaches.
History
Silver and colleagues at DeepMind had built AlphaGo, which beat a top human Go player in 2016. AlphaGo used human game records to start training, then reinforcement learning, and a search guided by networks. Its successor, AlphaGo Zero, removed the human records. It learned Go from self-play alone, with a single network that had both a policy head and a value head. The change showed that human data was not required to reach the top level in Go.
AlphaZero generalised that approach. The same algorithm, with the same network design and the same search, was applied to chess, shogi and Go, with only the game rules changed. The preprint appeared in late 2017 and the peer-reviewed version followed in 2018 in the journal Science. It caught on because it dropped the need for human knowledge in chess and shogi, where hand-written engines were strong, and because one algorithm covered three games.
Check yourself
QuestionRecall: what does the policy head of the AlphaZero network output, and what does the value head output?Show answer
The policy head outputs a probability for each legal move, which the search uses as a prior. The value head outputs a single number in , the predicted outcome for the player to move. Together they replace the hand-written evaluation and the random playouts of plain MCTS.
QuestionComputation: a node has total visits, and a move has prior , , . With , what is its PUCT score?Show answer
The mean is . The exploration term is . The score is .
QuestionWhy is the policy target taken from visit counts rather than from the network's own output?Show answer
The network output is a guess made in one forward pass. The visit counts come from many simulations that each check a move against the network's values, so the counts favour moves that held up under lookahead. Training the policy head toward them moves the network toward better moves than it could produce alone. This is the source of the improvement loop.
QuestionWhy does the value target come from the game result rather than from the search value?Show answer
The game result is a true outcome, so it is not limited by the network's own errors. Using the search value alone would teach the network to agree with its own search, with no outside signal. Using the outcome gives the value head a target that reflects what actually happened in the game.
QuestionApplied: you want to apply the AlphaZero recipe to a card game with hidden hands. Which parts of the method break down, and what would you change first?Show answer
Tree search with known next states assumes the player can see the full state. Hidden hands mean the state is not fully known, so the search needs to handle information sets rather than single positions. The first change would be to replace the search with a method that handles imperfect information, while keeping the self-play loop and the two-headed network. Without that change, the search would plan against cards the opponent may not hold.
Sources
- Silver et al., "Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm," arXiv:1712.01815. https://arxiv.org/abs/1712.01815
- AlphaZero (Wikipedia)
- Monte Carlo tree search (Wikipedia)