TL;DR
The paper shows that one general learning algorithm can reach superhuman play in chess, shogi and Go. The program starts from random play and is given only the rules. It learns by playing games against itself, and a single neural network both suggests moves and predicts who will win. Within a few hours it beat Stockfish at chess and Elmo at shogi, two engines built over decades from hand-written chess knowledge.
Builds on: AlphaZero, Monte Carlo Tree Search, Self-Play · Leads to: later general game-playing systems such as MuZero
Why it mattered
The paper turned the earlier AlphaGo Zero idea from one game into a recipe that works across games. Its training loop is the basis of later systems that learn from search and self-play, including open-source projects that reproduce the same method for chess. Before it, the strongest chess and shogi programs were alpha-beta engines tuned by experts, and the common belief was that search with handcrafted evaluation was the only route to top play. The paper showed a learned network guiding a much smaller search could match them. Semantic Scholar records about 2,250 citations for it.
The idea has a longer history. Computer chess has been a benchmark since the early days of computing, and Deep Blue beat the human world champion in 1997. AlphaGo beat a European professional Go champion in 2015 and the world champion Lee Sedol in 2016. AlphaGo Zero, in 2017, removed human games from Go training and learned from self-play alone. This paper applied that approach to chess and shogi, and it was posted to arXiv in December 2017.
The problem
The strong engines of the 2010s, such as Stockfish, work like this. They describe each position with a long list of features that experts chose, such as material, piece placement and king safety. They weight those features by hand and tune the weights. They search a huge tree of moves using alpha-beta search, a method that skips branches it can prove are not better than moves already found, and they add many domain-specific rules to make the search fast.
Each of those pieces is built for one game. Changing the game means rebuilding the feature list, the pruning rules and the opening book. The authors asked whether a single algorithm, given only the rules and no human knowledge, could learn to play at the top level in several games. For this to be a fair test it must learn by playing itself, with no human games, no opening book and no endgame tables.
Two ideas from Reinforcement Learning are needed. A policy says which move to play in a position. A value says how likely a position is to be won. Learning both from play is the setting for the whole paper.
How it works
Here is the training loop for one game, as the paper runs it. The example is chess, but the same loop runs for shogi and Go.
- Start with random weights. The network has parameters , set to random values. Its moves are close to random at first.
- Read the board. The position is encoded as a stack of planes, one for each piece type and colour, plus a few planes for special rules such as castling. The network sees the last eight positions, so it can tell where pieces came from.
- Ask the network for a guess. The network outputs two things: a probability for each legal move (the policy ) and one number between minus 1 and plus 1 that estimates how the game will end from this position (the value).
- Search with the guess. Monte Carlo Tree Search runs 800 simulations from the current position. Each simulation goes down the tree by picking moves that look promising under the network's prior and the average value found so far. Moves visited often become more trusted. The network's guess is the starting point, and the search corrects it.
- Pick a move from the visit counts. After 800 simulations, the search policy is the share of visits each move received. Suppose move A was visited 480 times, B 240 times and C 80 times. The search policy is then 60%, 30% and 10%.
- Play the game against yourself. Both sides use the same network and the same search. The game ends in a win, loss or draw, scored as , or for the player who was to move at each position.
- Train on the record. Each position from the game becomes a training example: the board , the search policy from step 5, and the final result . The network is updated so its value moves toward and its policy moves toward .
- Repeat with the new network. The next batch of self-play games uses the updated network. The search gets better targets, the network gets closer to them, and the loop continues.
Step 4 is the important one. The search gives targets better than the raw network, and training makes the raw network closer to the search. Each one improves the other.
flowchart LR A["Network guess (policy and value)"] --> B["MCTS: 800 simulations"] B --> C["Search policy from visit counts"] C --> D["Self-play game"] D --> E["Game result z"] C --> F["Training example (position, search policy, z)"] E --> F F --> G["Gradient step on loss"] G --> A
Take one position with two legal moves. The search gave . The network gives and . The side to move won, so . Leave out the regularisation term.
- Value term: .
- Policy term: , so .
- Negate it: .
- Add the two terms: .
The loss is about 1.05. The value term is the part the game result corrects directly.
The root of a search has three legal moves. After 800 simulations the visit counts are 480, 240 and 80. The network's prior is .
- Turn visits into the target: .
- Compute the logs of the network probabilities: , , .
- Multiply each by the target: , , .
- Sum them: .
- Negate: the cross-entropy is .
The search wants move 1 much more than the network does (0.6 against 0.2). A gradient step raises the network's probability for move 1 and lowers the others, so the next search starts from a better prior.
Table 1 of the paper reports 100-game matches with one minute of thinking per move. Chess: AlphaZero played 50 games as white and 50 as black against Stockfish. Summed over both colours, from AlphaZero's side, the record is 28 wins, 72 draws and 0 losses. Shogi against Elmo: 90 wins, 2 draws and 8 losses. Go against the earlier AlphaGo Zero (3 days of training): 60 wins and 40 losses.
- Take the shogi match. AlphaZero won 90, drew 2 and lost 8, so the three numbers add to 100.
- Give each draw half a point: .
- Divide by 100 games to get the score: .
- Do the same for chess: , a score of . Most chess games between these two programs ended in draws, so the score is lower even with no losses.
Try it: In the Go matches AlphaZero won 60 of 100 games. Compute its score the same way. Answer: the Go table has no draws, so the score is .
The math
The network is written , where is the position and are the network weights. The paper uses the following loss for each training position:
Reading it term by term:
- is the squared gap between the final game result and the value guess. It pushes the value toward the actual outcome. This is a Mean Squared Error term.
- is a Cross-Entropy Loss between the search policy and the network policy . It is smallest when the network puts the same probability on each move that the search did. The network's probabilities are normalised over the legal moves, as in a Softmax output.
- is an L2 Regularization penalty on the weights, with strength . It keeps the weights from growing without limit.
Step 4 in symbols
The search picks moves to explore with a rule that the paper says is the same as in AlphaGo Zero. For a position and move , the search keeps a visit count , an average value and the network prior , which is the move probability from . It picks the move that maximises , where is large when is large and is small. Moves get explored early when they look plausible, and the search keeps returning to moves that have worked. The search also adds noise drawn from a Dirichlet Distribution to the root priors, so a fixed plan is not always chosen. The Dirichlet concentration is set by the typical number of legal moves in each game, which the paper gives as 0.3 for chess, 0.15 for shogi and 0.03 for Go.
Step 5 in symbols
Let be the visit count of move at the root. The search policy is
The denominator is the total number of simulations, which is 800 during training. In Example 2 the counts are 480, 240 and 80, which sum to 800.
Step 7 in symbols
The value output should match , so is minimised. The policy output should match , so is minimised. Gradient descent adjusts to reduce the sum over a batch of positions. The paper uses mini-batches of 4,096 positions.
Results
Training ran for 700,000 steps with mini-batches of 4,096 positions. The self-play games used 5,000 first-generation TPUs and the network training used 64 second-generation TPUs. Figure 1 plots Elo rating against training steps. AlphaZero passed Stockfish in chess after about 4 hours (300,000 steps), passed Elmo in shogi after under 2 hours (110,000 steps), and passed AlphaGo Lee in Go after 8 hours (165,000 steps).
The final matches are in Table 1 and are summarised in Example 3. AlphaZero lost no games to Stockfish in chess, lost 8 of 100 games to Elmo in shogi, and beat the 3-day AlphaGo Zero 60 to 40 in Go. The paper also reports that AlphaZero searched about 80,000 positions per second in chess and 40,000 in shogi, against about 70 million for Stockfish and 35 million for Elmo. Figure 2 shows that its search gained more strength as thinking time grew than the alpha-beta engines did, which the authors read as evidence against the belief that alpha-beta is inherently better in these games.
Limits. The results are for one training run per game, with a fixed set of hyperparameters reused across games. The matches used one minute per move, and the comparison engines were run at their strongest setting on 64 threads, so the numbers describe these settings and not all possible ones.
Common misreadings. It is tempting to think AlphaZero learned chess by reading human games. In fact it used no human games, opening book or endgame tables; it started from random weights. It is tempting to think AlphaZero is better because it searches more. In fact it searches about 875 times fewer positions (70 million divided by 80,000). It is tempting to think a draw is a failure. In fact the value target is the game result, with draws at zero, so the value estimates an expected outcome rather than only the chance of winning. And it is tempting to think the network plays alone. In fact every move comes from the search's visit counts, and the raw policy only guides the search.
Tradeoffs. The method needs a lot of compute to train. It needs the rules as a simulator, so it does not directly apply where the rules are unknown. It is at its best when the game can be simulated quickly and the outcome can be scored. For a fixed budget of search, a strong alpha-beta engine with good features remains a sound choice; the paper's point is generality and learning.
Reading guide
The chain of ideas is: a network that guesses moves and outcomes, a search that improves the guess, self-play games that produce targets, and a training step that makes the network match the search. Read the paper's sections in this order.
- Abstract and Introduction: the claim and the comparison with Stockfish and Elmo. Needs AlphaZero.
- Introduction, the comparison with AlphaGo Zero: needs Self-Play and Reinforcement Learning.
- The description of the handcrafted chess engine the paper compares against: alpha-beta search prunes branches a minimax search would otherwise examine. Needs Minimax Game.
- The Methods section on search: how the tree is averaged over simulations and how the visit counts become the policy target. Needs Monte Carlo Tree Search.
- The Methods section on the network input and architecture: the input planes and the residual network. Needs Convolutional Neural Network and Deep Residual Learning for Image Recognition (ResNet).
- The Methods section on training settings: the learning rate, the Dirichlet noise and the L2 penalty. Needs Dirichlet Distribution and L2 Regularization.
- Results, the training curves and the match tables: read them against the numbers above.
Check yourself
QuestionWhich two quantities does the AlphaZero network output for a position, and what does each one estimate?Show answer
It outputs a policy , a probability for each legal move, and a value , a single number between minus 1 and plus 1 that estimates the expected outcome of the game from that position. The policy guides the search, and the value scores positions inside it.
QuestionA search with 800 simulations gives a root with visit counts 560, 200 and 40. What is the search policy ?Show answer
Divide each count by 800. The result is . Check: .
QuestionWhy does AlphaZero use the search policy as the training target for the policy output, instead of the move the game actually took?Show answer
The search policy is a better estimate of the best move than the raw network output, because it comes from hundreds of simulations that test the network's guesses. Training the network toward it passes the search's improvements into the network. The move actually played is a single sample, so it is a noisier target.
QuestionThe paper reports that AlphaZero searches about 80,000 positions per second in chess, and Stockfish about 70 million. Why does AlphaZero still win?Show answer
AlphaZero's network scores each candidate move with a learned guess, so the search spends its effort on the most promising lines. Stockfish examines far more positions but relies on hand-tuned features and fixed pruning rules. The paper argues that a selective search guided by a learned network is more effective per position examined.
QuestionA team trains AlphaZero on a new board game using the same code, and reports that the program reached strong play. Their report says the program was trained on a database of expert games. Why does that contradict the paper's setup?Show answer
The paper's setup uses only the game rules and self-play, with no human game records, no opening book and no endgame tables. A strong result from that setup comes from self-play alone. If the team used expert games, their run is a different method, and their result cannot be compared with the paper's claim of learning from first principles.
Sources
- Silver et al., "Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm," arXiv:1712.01815 (2017): https://arxiv.org/abs/1712.01815
- AlphaZero, Wikipedia: https://en.wikipedia.org/wiki/AlphaZero
- Monte Carlo tree search, Wikipedia: https://en.wikipedia.org/wiki/Monte_Carlo_tree_search