VerifiedarXiv:1712.0181535 min
Reinforcement learning · Search

AlphaZero: Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm

One algorithm, given only the rules, taught itself chess, shogi, and Go by playing against itself.

A neural network suggests moves and judges positions, a tree search uses those guesses to find better moves, and the network is trained to copy what the search found. Repeated over millions of games, the loop went from random play to Stockfish's strength in four hours of training.

Explaining the paperMastering Chess and Shogi by Self-Play with a General Reinforcement Learning AlgorithmSilver, Hubert, Schrittwieser, et al. · DeepMind · 2017 · arXiv:1712.01815 ↗

In December 2017 DeepMind showed that the method behind AlphaGo Zero needed almost nothing Go-specific. The same code, retrained from scratch on chess and on shogi, beat the world-champion program in each: Stockfish in chess and Elmo in shogi.

For at least four decades the strongest chess programs were built the same way. A programmer writes an evaluation function, a weighted sum of features such as material, pawn structure, king safety and mobility, and an alpha-beta search looks as many moves ahead as the clock allows, scoring the positions at the end of each line with that function and assuming both sides reply with their best move. The strongest engine of 2016, Stockfish, adds decades of refinements on top: an opening book, endgame tablebases, and a long list of pruning and move-ordering heuristics written for chess. The paper's Methods section lists them and then states that AlphaZero uses none.

AlphaZero replaces the evaluation function with a neural network and the alpha-beta search with a Monte-Carlo tree search, and it learns everything from games against itself, starting from random weights. The authors' phrase for this is tabula rasa, a blank slate. The only game knowledge it gets is the rules (which moves are legal, when a game is over, who won) and a fixed way of writing a board and a move as arrays of numbers. A separate copy was trained for each of chess, shogi and Go. The chess copy passed Stockfish after 4 hours of training, and in a 100-game match it won 28, drew 72 and lost none. The direct successor, MuZero, later removed the need to be told the rules.

Five pieces explain the paper, and the sections follow them in order: the self-play loop and why it improves; the network and its loss; the tree search that turns the network's guesses into better moves; the board and move encoding; and the paper's argument for why an averaging search suits a neural evaluator better than minimax. The last sections cover what changed from AlphaGo Zero, the results, and the criticism of the chess match.

How AlphaZero works: the self-play loop

The system has one network, (p,v)=fθ(s)(\mathbf{p}, v) = f_\theta(s). Given a position ss, it returns a vector p\mathbf{p} of move probabilities, with pa=Pr⁡(a∣s)p_a = \Pr(a \mid s) for each move aa, and a single number vv, its estimate of the final result of the game from this position. The result zz takes the value +1+1 for a win, 00 for a draw and −1-1 for a loss, from the point of view of the player to move, and vv is trained toward its expected value, v≈E[z∣s]v \approx \mathbb{E}[z \mid s]. For chess the input is an 8×8×119 array, p\mathbf{p} has 4,672 entries (one per possible move code, with illegal moves masked out), and vv is a scalar. One forward pass produces both outputs, with no look-ahead.

Before each move, AlphaZero runs a tree search from the current position: 800 simulations during training, each of which walks down a growing tree of future positions and asks the network to evaluate one new position. The search returns a second distribution over moves, written π\boldsymbol{\pi}, proportional to how often it visited each move. Because the search starts from p\mathbf{p} and then checks the consequences of the moves it considers, π\boldsymbol{\pi} is usually a stronger policy than p\mathbf{p}. AlphaGo Zero called the search a policy-improvement operator for this reason: it takes the network's policy as input and outputs a better one, at the cost of 800 network calls instead of one.

Self-play turns that improvement into training data. AlphaZero plays a full game against itself, choosing every move from π\boldsymbol{\pi}, and records each position together with the π\boldsymbol{\pi} computed there. When the game ends, the rules give the result, and every recorded position gets the label zz from the side that was to move there: if White won, positions with White to move get z=+1z = +1 and positions with Black to move get z=−1z = -1. An 80-move game therefore yields 80 training examples (s,π,z)(s, \boldsymbol{\pi}, z). The network is trained to move p\mathbf{p} toward π\boldsymbol{\pi} and vv toward zz. The next search then starts from the updated prior and value estimate, so its targets improve again.

This alternation of evaluating a policy and improving it is policy iteration, a standard scheme in reinforcement learning, with the network as the fast policy and the search as the improvement step. The same split appears in the independent Expert Iteration paper from the same year, which calls the search the "expert" and the network the "apprentice" and demonstrated it on the board game Hex. The figure runs the loop: the four stages go round, and the bar at the bottom fills as successive laps raise the network's strength.

Figure 1 · the self-play loop
net
Press Play or scrub. The network turns a position into a prior p and value v; the search sharpens p into a stronger policy π; self-play follows π to an outcome z; training pushes p toward π and v toward z. The strength bar climbs with each lap.

No human games enter this loop. The whole procedure for one game fits in a few lines:

# one self-play game, then the learning update
s, history = start_position(), []
while not s.terminal():
    pi = mcts(s, net, sims=800)     # visit-count policy over legal moves
    history.append((s, pi, s.to_move))
    a = sample(pi)                  # training games: proportional to visits
    s = s.apply(a)
result = s.outcome_for_white()      # +1, 0 or -1 under the real rules
for (s, pi, player) in history:
    z = result if player == WHITE else -result   # outcome for the mover
    grad_step(net, s, pi, z)  # minimise (z - v)^2 - pi . log p + c||theta||^2

The value target is the actual result of the game, the same number (up to sign) for every position in it. There is no intermediate reward and no bootstrapped estimate. The Q-learning target in DQN, by contrast, is built from the network's own estimate of the next state's value. A game outcome is an unbiased sample of how the current policy does from that position, and its cost is variance: one blunder near the end relabels every position in the game.

The network and its loss

The network is a deep residual network: a stack of convolutional residual blocks that reads the board as an image, with a policy head that outputs p\mathbf{p} and a value head that outputs vv on top of a shared body. The preprint does not restate the architecture; it says the network and the training settings are those of AlphaGo Zero unless noted. AlphaGo Zero's Methods describe 256-filter 3×3 convolutions with batch normalization and ReLU, in towers of 19 or 39 residual blocks after an initial convolution. The original AlphaGo used two separate networks for policy and value; AlphaGo Zero merged them so one set of features serves both outputs.

Each training example is a position ss, the search policy π\boldsymbol{\pi} computed there, and the game result zz. The loss, minimised by gradient descent, is

l=(z−v)2  −  π⊤log⁡p  +  c ∥θ∥2l = (z - v)^2 \;-\; \boldsymbol{\pi}^\top \log \mathbf{p} \;+\; c\,\lVert\theta\rVert^2
(1)

The first term is the squared error between the predicted value vv and the actual result zz. The second is the cross-entropy between the search policy π\boldsymbol{\pi} and the network's policy p\mathbf{p}. The minus sign in front makes it non-negative, since every log⁡pa\log p_a is at most 0, and for a fixed π\boldsymbol{\pi} it is smallest exactly when p=π\mathbf{p} = \boldsymbol{\pi}. The paper's prose says the update should "maximise the similarity of the policy vector p\mathbf{p} to the search probabilities π\boldsymbol{\pi}"; that is the same objective with the sign flipped. The third term is L2 weight regularisation with coefficient cc. The preprint gives no value for cc; AlphaGo Zero used 10−410^{-4}.

A worked example with three legal moves. The game was won, so z=+1z = +1, and the network predicted v=0.2v = 0.2. The search visited the moves in proportions π=(0.7,0.2,0.1)\boldsymbol{\pi} = (0.7, 0.2, 0.1), and the network's policy was p=(0.4,0.4,0.2)\mathbf{p} = (0.4, 0.4, 0.2). Then

(1−0.2)2=0.64,−(0.7ln⁡0.4+0.2ln⁡0.4+0.1ln⁡0.2)=0.986(1 - 0.2)^2 = 0.64, \qquad -\big(0.7 \ln 0.4 + 0.2 \ln 0.4 + 0.1 \ln 0.2\big) = 0.986(1−0.2)2=0.64,−(0.7ln⁡0.4+0.2ln⁡0.4+0.1ln⁡0.2)=0.986\begin{gathered} (1 - 0.2)^2 = 0.64, \\ -\big(0.7 \ln 0.4 + 0.2 \ln 0.4 + 0.1 \ln 0.2\big) = 0.986 \end{gathered}

If the network had output p=π\mathbf{p} = \boldsymbol{\pi}, the policy term would be 0.802, the entropy of π\boldsymbol{\pi}, which is the floor for this target. With a softmax output layer, the gradient of the policy term with respect to the network's logits is p−π\mathbf{p} - \boldsymbol{\pi}, here (−0.3,0.2,0.1)(-0.3, 0.2, 0.1): the update raises the logit of the search's favourite and lowers the other two. The value gradient pushes vv up from 0.2 toward 1. Both gradients flow into the shared body.

Two design choices in (1) have obvious alternatives. Training p\mathbf{p} toward the whole visit distribution, rather than toward the one move that was played, gives the network the search's ranking of every move it considered, including the second- and third-best, instead of one sampled index. Using the game result zz as the value target, rather than the search's own value estimate, keeps the target unbiased; MuZero later switched to a bootstrapped target built from search values, trading some bias for lower variance.

The training configuration is the same for all three games: 700,000 steps with mini-batches of 4,096 positions (about 2.9 billion position samples), and a learning rate of 0.2 dropped three times, to 0.02, 0.002 and 0.0002. Self-play games came from 5,000 first-generation TPUs and training ran on 64 second-generation TPUs. The split reflects the cost: every move of every self-play game costs 800 network evaluations, while a training step costs one batch. In chess, 44 million self-play games were played in 9 hours.

The search is AlphaGo Zero's, unchanged. The AlphaZero preprint describes it in one sentence (each simulation picks moves with "low visit count, high move probability and high value") and defers to AlphaGo Zero for the formulas, which are given below from that paper's Methods. The settings AlphaZero states are 800 simulations per move in training and the root noise of the next section.

The search builds a tree whose root is the position to move from. Each edge, meaning a move aa from a position ss, stores four numbers: the visit count N(s,a)N(s,a), the total value W(s,a)W(s,a) backed up through it, the mean value Q(s,a)=W(s,a)/N(s,a)Q(s,a) = W(s,a)/N(s,a), and the prior P(s,a)P(s,a) that the network assigned when ss was first evaluated. One simulation has three steps. It selects a path from the root, at each node choosing the aa that maximises

Q(s,a)+U(s,a),U(s,a)=cpuct P(s,a) ∑bN(s,b)1+N(s,a)Q(s,a) + U(s,a), \qquad U(s,a) = c_{\text{puct}}\, P(s,a)\, \frac{\sqrt{\sum_b N(s,b)}}{1 + N(s,a)}Q(s,a)+U(s,a),U(s,a)=cpuct P(s,a) ∑bN(s,b)1+N(s,a)\begin{gathered} Q(s,a) + U(s,a), \\ U(s,a) = c_{\text{puct}}\, P(s,a)\, \frac{\sqrt{\sum_b N(s,b)}}{1 + N(s,a)} \end{gathered}
(2)

until it reaches a position that has not been expanded. It then expands that leaf: the network evaluates it once, its value vv becomes the simulation's result, and its policy output becomes the priors PP of the new edges, which start with N=W=Q=0N = W = Q = 0. If the leaf is a finished game, the rules score it instead. Last, it backs up: every edge on the path gets N+=1N \mathrel{+}= 1 and W+=vW \mathrel{+}= v, so QQ stays the mean of all leaf values that passed through the edge. In a two-player game the value is stored from the point of view of the player choosing at each edge, so its sign flips at every level of the tree; the papers leave this bookkeeping implicit. There is no random playout to the end of the game, which the original AlphaGo and classical Monte-Carlo tree search used. "Monte-Carlo" here refers to the averaging of leaf evaluations in QQ.

In (2), Q(s,a)Q(s,a) favours moves whose explored consequences have scored well, and U(s,a)U(s,a) is an exploration bonus, scaled by a constant cpuctc_{\text{puct}} that sets how much exploration counts against the value QQ. The bonus is proportional to the prior, so the network's favourite moves are tried first, and it shrinks like 1/(1+N)1/(1+N) as a move collects visits, so attention moves on to other candidates. The numerator grows with the parent's total visit count, so the bonus of an unvisited move keeps rising as the other moves are explored. This is PUCT, a variant of Rosin's 2011 bandit rule. It has no logarithm, unlike the UCB1 rule of classical Monte-Carlo tree search; the square root is over the parent's total visits, and the +1+1 keeps an unvisited move's bonus finite.

A worked step, using the toy numbers in Figure 2 with cpuct=1.25c_{\text{puct}} = 1.25. Six moves have priors 0.30,0.10,0.08,0.22,0.18,0.120.30, 0.10, 0.08, 0.22, 0.18, 0.12 for aa to ff, and in this toy each move's leaf evaluations always return the same value, 0.42 for aa and 0.78 for dd (the best). The first five simulations all go to aa, the prior's favourite. At the sixth, the root has 5 visits in total, so the score of aa is

0.42+1.25×0.30×51+5=0.42+0.140=0.5600.42 + 1.25 \times 0.30 \times \frac{\sqrt{5}}{1 + 5} = 0.42 + 0.140 = 0.5600.42+1.25×0.30×51+5=0.42+0.140=0.560\begin{aligned} &0.42 + 1.25 \times 0.30 \times \frac{\sqrt{5}}{1 + 5} \\ &= 0.42 + 0.140 = 0.560 \end{aligned}

while the unvisited dd, with Q=0Q = 0, scores from its bonus alone

0+1.25×0.22×51+0=0.6150 + 1.25 \times 0.22 \times \frac{\sqrt{5}}{1 + 0} = 0.615

The search tries dd, sees 0.78, and from then on dd keeps winning the comparison: after 20 simulations it has 12 visits to aa's 5. When the simulations run out, AlphaZero picks what to play from the visit counts, not from QQ:

π(a∣s)  ∝  N(s,a)1/τ\boldsymbol{\pi}(a \mid s) \;\propto\; N(s,a)^{1/\tau}
(3)

The temperature τ\tau controls how greedy the choice is. At τ=1\tau = 1 moves are sampled in proportion to their visits; as τ→0\tau \to 0 the choice becomes the most-visited move. AlphaGo Zero used τ=1\tau = 1 for the first 30 moves of each self-play game and τ→0\tau \to 0 afterwards. The AlphaZero preprint states that training moves are "selected in proportion to the root visit count" and that evaluation games play the most-visited move. Visit counts are used because a move only accumulates visits after its QQ has held up over many simulations, while the QQ of a rarely visited move can rest on one or two leaf evaluations. The same normalised visit counts are the target π\boldsymbol{\pi} in loss (1).

In the figure, the amber dashed ticks are the network's prior over the six moves, and the teal bars are the share of simulations each move has received so far, with its value QQ printed above once visited. Scrub the simulations to watch the visits start on aa and move to dd. Then drag cpuctc_{\text{puct}} to its ends. Below about 0.2 the search never tries dd: the bonus is too small for any unvisited move to beat 0.42. At 10 the bonus dominates for all 160 simulations and the visits stay close to the prior.

Figure 2 · search improves the policy
160 sims
1.25
Scrub or play the 160 simulations; slide c_puct from 0.05 to 10. The prior P favours a; the visit shares π shift to d, which has the best look-ahead value, once its bonus earns it a first visit. AlphaGo Zero prints no c_puct value; 1.25 is this figure's default.

A simulation is select, expand, back up. In pseudocode, with the sign flip written out:

# one of the 800 simulations
node, path = root, []
while node.is_expanded:                      # 1. SELECT by PUCT
    a = argmax(Q(node, b) + c_puct * P(node, b) * sqrt(N_total(node))
               / (1 + N(node, b))  for b in node.legal_moves)
    path.append((node, a))
    node = node.child(a)
if node.terminal:
    v = node.score_by_rules()                # rules score a finished game
else:
    p, v = net(node.state)                   # 2. EXPAND: one network call,
    node.expand(priors=mask_illegal(p))      #    no random playout
for (s, a) in reversed(path):                # 3. BACK UP
    v = -v                                   # value for the player at s
    N[s, a] += 1; W[s, a] += v; Q[s, a] = W[s, a] / N[s, a]

Running it 800 times and reading off the root visit counts gives both the next move and the policy target for training. The chess network at training time spent about 40 ms on those 800 simulations; shogi took 80 ms and Go 200 ms.

Root noise, the one per-game setting

If self-play always followed the search, it would keep playing the lines the current network already likes, and a good move with a low prior might never get the visit that reveals its value. AlphaGo Zero fixed this by mixing random noise into the priors at the root of each search, and AlphaZero keeps the mechanism:

P(sroot,a)=0.75 pa+0.25 ηa,η∼Dir⁡(α)P(s_{\text{root}}, a) = 0.75\, p_a + 0.25\, \eta_a, \qquad \boldsymbol{\eta} \sim \operatorname{Dir}(\alpha)
(4)

η\boldsymbol{\eta} is a random probability vector over the legal moves, drawn from a symmetric Dirichlet distribution. The weight 0.25 is AlphaGo Zero's ε\varepsilon. Only the root gets noise; deeper nodes use the network's priors as they are. The concentration α\alpha sets the shape of the noise. With α\alpha much smaller than 1, nearly all of η\boldsymbol{\eta} lands on one or two random moves; with α\alpha much larger than 1, η\boldsymbol{\eta} is close to uniform and adds the same small amount to every move.

α\alpha is the one hyperparameter AlphaZero sets per game: 0.3 for chess, 0.15 for shogi and 0.03 for Go, "scaled in inverse proportion to the approximate number of legal moves in a typical position". A typical chess position has about 35 legal moves and a Go position about 250. The inverse scaling keeps one quantity roughly fixed. For a symmetric Dirichlet over nn moves, the expected sum of squared shares is (1+α)/(nα+1)(1+\alpha)/(n\alpha+1), so the effective number of moves the noise covers is about

neff=nα+11+α:35×0.3+11.3=8.8 (chess),250×0.03+11.03=8.3 (Go)n_{\text{eff}} = \frac{n\alpha + 1}{1 + \alpha}: \qquad \frac{35 \times 0.3 + 1}{1.3} = 8.8 \text{ (chess)}, \qquad \frac{250 \times 0.03 + 1}{1.03} = 8.3 \text{ (Go)}neff=nα+11+α:35×0.3+11.3=8.8 (chess),250×0.03+11.03=8.3 (Go)\begin{gathered} n_{\text{eff}} = \frac{n\alpha + 1}{1 + \alpha}: \\ \frac{35 \times 0.3 + 1}{1.3} = 8.8 \text{ (chess)}, \\ \frac{250 \times 0.03 + 1}{1.03} = 8.3 \text{ (Go)} \end{gathered}

In both games the noise pushes extra prior mass onto roughly eight or nine random moves. Using chess's 0.3 in Go would spread the noise across about 58 moves, each getting too little to matter; using Go's 0.03 in chess would put it on about two. In the figure, the bars are one draw of η\boldsymbol{\eta} sorted from the largest share to the smallest. Switch the game, drag α\alpha across its range, and press new draw a few times.

Figure 3 · Dirichlet noise at the root
0.30
Toggle chess or Go (α resets to the paper's value), drag α from 0.01 to 3, and redraw. The bright bars are the moves the noise effectively covers in this draw. At α = 0.01 one move takes almost everything; at α = 3 every bar sits near the uniform line.

The 35 and 250 are the usual textbook branching factors; the preprint says only "the approximate number of legal moves" and does not give its counts. The paper's list of the domain knowledge given to AlphaZero names this number as item (iv), next to the rules and the encodings.

The board and the moves as planes

A convolutional network needs its input as a grid of numbers, so AlphaZero writes a position as a stack of N×NN \times N planes, each plane a binary or constant-valued feature over the board. The same convolution filters slide over every square, which suits board games, where the same local patterns matter everywhere. The board is always oriented from the point of view of the player to move.

The input is an N×N×(MT+L)N \times N \times (MT + L) stack. The MM planes describe one position: one plane per piece type for each player, and repetition counts. They are repeated for the last T=8T = 8 positions (zeros before the game began), so the network sees how the position arose. The LL constant planes are added once: whose turn it is, the move number, and for chess the four castling rights and the no-progress counter that drives the 50-move rule. Only the per-step block is multiplied by 8. Chess has 6 + 6 piece planes and 2 repetition planes per step, plus 7 constants, for 14×8+7=11914 \times 8 + 7 = 119 planes. Shogi adds 14 prisoner-count planes per step (7 captured-piece types per player) to 14 + 14 piece planes and 3 repetition planes, plus 2 constants, for 45×8+2=36245 \times 8 + 2 = 362. Go needs one stone plane per player and a colour plane, 2×8+1=172 \times 8 + 1 = 17.

The policy output is a stack of planes too. A chess move is "pick up the piece on this square, then make this kind of move", so each of the 64 squares is crossed with 73 move types: 56 "queen moves" (8 compass directions × distances 1 to 7), 8 knight jumps, and 9 underpromotions. That is 8×8×73=4,6728 \times 8 \times 73 = 4{,}672 codes, most of them illegal in any given position; illegal codes are masked to probability zero and the rest renormalised. Shogi uses 9×9×139=11,2599 \times 9 \times 139 = 11{,}259: 64 queen-move planes, 2 knight planes, the same 64 + 2 again for moves that promote, and 7 planes for dropping a captured piece of each type onto a square, a rule that widens shogi's game tree well beyond chess's. Go keeps AlphaGo Zero's flat list of 19×19+1=36219 \times 19 + 1 = 362 moves (every point plus pass). Toggle the game and hover a band of the output bar to see each group:

Figure 4 · board and moves as planes
119 input · 4,672 moves
Toggle chess, shogi or Go; hover a move group. The input is N×N×(M·8+L): per-step planes over an 8-position history plus constants. The policy output is N×N×P, every square crossed with the move types. All counts are from the paper's Tables S1 and S2.

The name "queen moves" describes a geometry that every sliding piece shares. Those 56 planes hold every straight-line move of any piece: a rook sliding three squares north, a bishop sliding one square northeast, a king step, a pawn push or a pawn capture. The piece itself is not part of the code; the network finds it in the input planes. A pawn that reaches the last rank through an ordinary queen-move plane promotes to a queen, so only promotions to knight, bishop or rook need the 9 extra planes (3 pieces × push, capture left, capture right). Place a piece and hover the highlighted squares to read the plane each move uses:

Figure 5 · which move planes a piece uses
Pick a piece, click a square to move it, hover (or tap) a highlighted square. Teal targets use queen-move planes, amber knight planes, and violet marks a pawn on rank 7, whose three moves also carry underpromotion planes. Castling is omitted: the preprint does not say how it is encoded.

A queen on d4 uses 27 of the 73 planes on an empty board, a queen in the corner 21, a knight in the corner 2. The paper also tried a flat list of moves for chess and shogi and reports that "the final result was almost identical although training was slightly slower", so the plane layout mainly speeds up training.

Why an averaging search can beat minimax

AlphaZero examines far fewer positions than the engines it beat: 80 thousand per second in chess against Stockfish's 70 million, and 40 thousand in shogi against Elmo's 35 million, roughly a thousand times fewer. Each AlphaZero evaluation is a pass through a deep network, while Stockfish's is a handcrafted linear formula plus a short tactical search. The paper's explanation for why the slower search still wins concerns how each search combines its leaf evaluations.

An alpha-beta engine computes a minimax value. It scores the positions at the end of each line, then backs the scores up the tree by taking the maximum at nodes where it moves and the minimum where the opponent moves. Alpha-beta pruning skips branches that provably cannot change the result, so it returns exactly the minimax value of the scored leaves. If the leaf scores are accurate, that is the right value. If they are noisy, the max and min select the extreme scores: among many leaves of similar true value, the one with the largest error in the favourable direction wins each comparison and travels up to the root. The paper puts it as "alpha-beta search computes an explicit minimax, which propagates the biggest approximation errors to the root of the subtree", and argues that a deep network, more expressive than a linear evaluation but prone to occasional spurious errors, makes this worse. MCTS instead averages leaf evaluations within a subtree, and independent errors in an average partly cancel.

Figure 6 tests the argument on a small tree. You choose among moves A, B and C; the opponent then has KK replies to each. All replies to a move have the same true value, 0.50 for A, 0.55 for B and 0.45 for C, so an exact evaluator gives the same answer either way: play B, worth 0.55. The evaluator adds independent Gaussian noise of standard deviation σ\sigma to each leaf. Minimax values each move at the minimum of its noisy leaves, and the expected minimum of KK noisy copies of one number sits below that number:

E[min⁡j≤K(x+σϵj)]=x−cK σ,c2=0.56,  c4=1.03,  c16=1.77\mathbb{E}\big[\min_{j \le K} (x + \sigma \epsilon_j)\big] = x - c_K\,\sigma, \qquad c_2 = 0.56,\; c_4 = 1.03,\; c_{16} = 1.77E[min⁡j≤K(x+σϵj)]=x−cK σ,c2=0.56,  c4=1.03,  c16=1.77\begin{gathered} \mathbb{E}\big[\min_{j \le K} (x + \sigma \epsilon_j)\big] = x - c_K\,\sigma, \\ c_2 = 0.56,\; c_4 = 1.03,\; c_{16} = 1.77 \end{gathered}

where the ϵj\epsilon_j are standard normal. The average of the same KK leaves has no such bias and its noise shrinks like σ/K\sigma/\sqrt{K}. Over many random draws at σ=0.1\sigma = 0.1 and K=4K = 4, minimax picks a move other than B about 36% of the time and its root value averages 0.08 too low; averaging picks wrong about 27% of the time with a root error near +0.01. At K=16K = 16 the minimax error rate is still 28% and its root value is 0.16 too low, while averaging is wrong 8% of the time. At K=1K = 1 the two backups are identical.

Figure 6 · minimax and averaging over a noisy evaluator
0.10
4
Drag the noise σ (0 to 0.3) and the reply count K (1 to 16); press new draw for fresh noise. The tree shows one draw: min and mean under each move, and each backup's choice. The bottom rows are over 2,000 draws: how often each picks a move other than B, and its mean root error against 0.55.

The toy has two limits. Plain averaging over all replies would be wrong if one reply were genuinely much better for the opponent; MCTS does not average uniformly, because its visits concentrate on the replies that look best for the side to move, so its QQ values approach the minimax line as visits grow while still pooling many evaluations. The cancellation also assumes the network's errors are roughly independent and unbiased; a blind spot shared across many similar positions survives averaging. The paper offers this as an explanation for why the combination works ("Using MCTS may allow AlphaZero to effectively combine its neural network representations with a powerful, domain-independent search"), without a proof, and notes that earlier chess programs using MCTS had been much weaker than alpha-beta programs.

The contrast goes back to Claude Shannon's 1950 paper on computer chess, which the preprint cites: a "Type A" program searches every line to a fixed depth, while a "Type B" program looks selectively at the promising moves, as a human does. AlphaZero is a Type B searcher, spending its much smaller budget where its network points. (Stockfish 8's evaluation was handcrafted and linear; the neural NNUE evaluation that Stockfish adopted arrived in 2020, after this paper.) The paper's Figure 2 measures how each program's strength grows with thinking time, in Elo relative to Stockfish or Elmo at 40 ms per move. AlphaZero's MCTS gained more from extra time than either alpha-beta engine, "calling into question the widely held belief that alpha-beta search is inherently superior in these domains". Toggle the game and slide the time per move:

Figure 7 · scaling with thinking time
vs Stockfish
Toggle chess or shogi; slide the thinking time from 40 ms to about 40 s. Both players improve, but AlphaZero gains faster than the alpha-beta engine, so its lead widens. The slopes are illustrative of the shape of the paper's Figure 2; the positions-per-second figures are exact.

What changed from AlphaGo Zero

AlphaZero is AlphaGo Zero with four Go-specific assumptions removed. Removing them let the same code run on chess and shogi.

Draws. AlphaGo Zero estimated and optimised the probability of winning, assuming every game ends in a win or a loss, as Go games do under the scoring it used. Chess and shogi have draws, and the optimal result of chess is widely believed to be a draw. AlphaZero estimates the expected outcome instead, with z∈{−1,0,+1}z \in \{-1, 0, +1\} and a draw scored 0. Loss (1) did not change; only the meaning of its target did.

Symmetry. The rules of Go are unchanged by rotating or reflecting the board, and AlphaGo Zero used this twice: it augmented its training data with the 8 symmetries of each position, and during search it applied a random rotation or reflection to each position before evaluating it. Chess and shogi are asymmetric (pawns move only forward, kingside and queenside castling differ), so AlphaZero does neither.

The best-player gate. AlphaGo Zero generated self-play games with the best player so far, and after each training iteration a new network replaced it only if it won by a margin of 55% in an evaluation match. AlphaZero keeps one network that is updated continually and generates its games with the latest parameters, with no evaluation step and no gate.

Per-game tuning. AlphaGo Zero tuned its search hyperparameters by Bayesian optimisation. AlphaZero uses the same hyperparameters for all three games, except the noise concentration α\alpha from (4).

The paper lists exactly what domain knowledge remains. (i) The input and output are planes matched to the board. (ii) The rules are used inside the search to compute the position after a move, detect the end of a game, and score it. (iii) The rules also define the special input planes (castling, repetition, no-progress) and the output planes (how pieces move, promotions, shogi drops). (iv) The typical number of legal moves sets the noise. (v) Chess and shogi games longer than a maximum length, set from typical game lengths, are stopped and scored as draws. And "one algorithm, three games" means three separately trained networks; no single set of weights plays all three.

Results against Stockfish, Elmo and AlphaGo Zero

Starting from random weights, AlphaZero passed Elmo, the Computer Shogi Association world champion, after less than 2 hours (110 thousand steps); Stockfish 8, the 2016 TCEC world champion, after 4 hours (300 thousand steps); and AlphaGo Lee, the version that beat Lee Sedol, after 8 hours (165 thousand steps). Wall-clock time and step count differ because a step takes longer to generate in some games: the full 700 thousand steps took 9 hours for chess, 12 for shogi and 34 for Go, from 44, 24 and 21 million self-play games. The abstract's "within 24 hours" refers to these crossings; the Go run as a whole took 34 hours.

Figure 8 · learning from scratch
420k of 700k (9h)
Toggle the game and scrub the training steps. The teal curve is AlphaZero's strength, the dashed line the champion program it is chasing, and the marker the crossing the paper reports (chess 300k steps, shogi 110k, Go 165k). The curve follows the qualitative shape of the paper's Figure 1; the y-axis is relative strength, not its Elo values.

The fully trained networks then played 100-game matches at one minute per move, AlphaZero on a single machine with 4 TPUs and Stockfish and Elmo on 64 CPU threads with a 1 GB hash table:

Game (opponent)AlphaZero as WhiteAlphaZero as BlackTotal W / D / L
Chess (Stockfish 8)25 / 25 / 03 / 47 / 028 / 72 / 0
Shogi (Elmo)43 / 2 / 547 / 0 / 390 / 2 / 8
Go (AlphaGo Zero, 3 days)31 / – / 1929 / – / 2160 / – / 40

"Undefeated" applies only to the chess match. Against Elmo AlphaZero lost 8 games, and against the three-day AlphaGo Zero it lost 40 of 100; footnote 2 of the paper adds that AlphaGo Zero and AlphaGo Master were ultimately trained for 100 times this length of time. In chess, AlphaZero won 25 of its 50 games as White and 3 of 50 as Black, drawing the rest. Resignation was enabled (Stockfish and Elmo resigned after 10 consecutive moves evaluated at −900 centipawns, AlphaZero below a 5% estimated win rate) and pondering on the opponent's time was disabled.

A second chess experiment, the paper's Table 2, started games from the 12 most common human openings, each played more than 100,000 times in an online database, with 50 games per colour per opening. AlphaZero had found each of these openings on its own during self-play and played them often. Across the 1,200 games it scored 242 wins, 353 draws and 5 losses as White and 48 wins, 533 draws and 19 losses as Black, so it lost 24 games once it was forced into lines it might not have chosen.

The chess match drew criticism soon after the preprint appeared, mostly about the conditions given to Stockfish. A fixed minute per move removes the time management an engine normally uses to spend more time on critical positions; a 1 GB hash table is small for a 64-thread search; and the preprint does not mention an opening book or endgame tablebases, which suggests (but does not state) that Stockfish ran without them. The peer-reviewed version (Silver et al., Science, 2018) replayed the chess match over 1,000 games at 3 hours per game plus 15 seconds per move, with Stockfish on 44 CPU cores, a 32 GB hash and Syzygy endgame tablebases. The main match was again against Stockfish 8; AlphaZero won 155 games and lost 6, the rest drawn, and additional matches against the January 2018 development version of Stockfish gave very similar results. Those numbers come from the 2018 paper; everything else on this page is from the December 2017 preprint.

How the paper measures strength

The training curves are in Elo ratings, computed from a tournament at 1 second per move between AlphaZero checkpoints and the baseline program, with the baselines anchored to their published ratings. The Methods give the model as a logistic function of the rating difference, with ratings fitted by Bayesian logistic regression in the BayesElo program:

p(a defeats b)=11+exp⁡(celo (e(b)−e(a))),celo=1400p(a \text{ defeats } b) = \frac{1}{1 + \exp\big(c_{\text{elo}}\,(e(b) - e(a))\big)}, \qquad c_{\text{elo}} = \tfrac{1}{400}p(a defeats b)=11+exp⁡(celo (e(b)−e(a))),celo=1400\begin{gathered} p(a \text{ defeats } b) = \frac{1}{1 + \exp\big(c_{\text{elo}}\,(e(b) - e(a))\big)}, \\ c_{\text{elo}} = \tfrac{1}{400} \end{gathered}
(5)

Equation (5) is printed with exp⁡\exp, a base-ee logistic. The familiar Elo convention, and the one BayesElo implements, is base 10: 1/(1+10(e(b)−e(a))/400)1/(1 + 10^{(e(b) - e(a))/400}). The two differ by a factor of ln⁡10=2.30\ln 10 = 2.30 in the scale. Read literally, (5) gives a player 400 points stronger a win probability of 1/(1+e−1)1/(1+e^{-1}), which is 73.1%, odds of 2.72 to 1. The usual rule that 400 points means 10-to-1 odds (90.9%) comes from the base-10 form and does not follow from (5) as printed. For a sense of scale, AlphaZero's 64% score against Stockfish (28 wins plus half of 72 draws) corresponds, by the textbook calculation, to about 100 points in base 10 or 230 points under the printed form. BayesElo models draws separately, so these two numbers only illustrate the size of the difference.

Figure 9 · two readings of the Elo formula
400 pts
Slide the rating gap from 0 to 800. Teal: equation (5) as printed, with exp. Amber: the base-10 Elo curve. The dotted lines mark AlphaZero's 64% score against Stockfish and the gap each curve assigns to it.

Footnote 3 of the paper adds a caution about comparing gaps across games: the prevalence of draws in high-level chess compresses the Elo scale relative to shogi or Go, so a chess gap and a shogi gap of the same size do not mean the same margin of play.

Provenance Verified against primary literatureHow we verify
AlphaGo Zero (Silver et al., Nature 2017)The search (PUCT selection, N/W/Q/P edge statistics, backup, visit-count policy with temperature), root noise with epsilon = 0.25, tau = 1 for the first 30 self-play moves, the dual-head residual network and c = 1e-4. AlphaZero reuses all of it; the preprint prints none of these formulas.
Rosin (2011)The PUCT bandit rule that AlphaGo Zero adapted. Its exploration bonus uses the square root of the parent visit count and has no logarithm.
Expert Iteration (Anthony, Tian, Barber, 2017)The same split into a search "expert" and a network "apprentice", found independently and demonstrated on Hex.
AlphaGo (Silver et al., Nature 2016)The earlier program: trained first on human games, used rollouts to the end of the game, and kept separate policy and value networks.
Shannon (1950)Type A (full-width) versus Type B (selective) search, the framing for the thousandfold gap in positions per second.
Silver et al., Science (2018)The peer-reviewed rerun: 1,000 chess games at 3 h + 15 s per move against Stockfish 8 with 44 cores, 32 GB hash and Syzygy tablebases; +155 -6, with similar results against a January 2018 Stockfish development version.
correctionTwo slips in the preprint, and one caveat about its chess match. (1) The preprint states the noise scaling both ways. Its Configuration section says Dirichlet noise "was scaled in inverse proportion to the approximate number of legal moves in a typical position", while its list of differences from AlphaGo Zero says the noise "is scaled in proportion to the typical number of legal moves". The values (0.3 for chess, about 35 moves; 0.03 for Go, about 250) are inverse, and this page teaches inverse. (2) The Elo model is printed as 1/(1 + exp(c(e(b) - e(a)))) with c = 1/400, but BayesElo, which computed the ratings, is base 10. Read literally, the printed formula makes a 400-point gap 2.72:1 (73%), not the familiar 10:1 (91%); this page shows the printed form and does not derive the 10:1 rule from it. (3) The headline chess match gave Stockfish a fixed minute per move and a 1 GB hash for 64 threads, and the preprint never mentions an opening book or tablebases; "no book, no tablebases" is an inference from that silence. The 2018 Science version replayed the match under tournament conditions and AlphaZero still won clearly.

Questions you might still have

?

Why is the search stronger than the network it is built from?
Because it spends computation looking ahead. With the weights held fixed, 800 simulations that check the consequences of candidate moves pick better moves than one forward pass of the network. Training does not create that advantage; it copies the search’s choices into the network so the next search starts from better priors and better value estimates.

?

If the network starts random, what stops self-play from learning nonsense?
The rules. Games end in real wins, draws and losses that the network cannot influence except by playing better, and the search uses the rules to score finished games inside its tree. Whatever the current network is, the search improves on it, so each round’s targets are slightly better than the network that produced them.

?

Is it one network for all three games?
No. A separate instance was trained from scratch for each of chess, shogi and Go. The algorithm and hyperparameters are shared, apart from the Dirichlet noise concentration alpha, and the input and output plane sizes differ by game.

?

Why play the most-visited move instead of the move with the highest Q?
A move only collects many visits after its value has held up across many simulations, so the visit count is a more reliable signal than the mean value of a move that might have been visited once or twice. The normalised visit counts are also the training target for the policy head, so the move choice and the target come from the same statistic.

?

Did AlphaZero really beat Stockfish fairly?
The 2017 preprint’s match was criticized: Stockfish had a fixed minute per move, a 1 GB hash, and apparently no opening book or tablebases. The 2018 Science version replayed 1,000 games at 3 hours plus 15 seconds per move with 44 cores, a 32 GB hash and Syzygy tablebases, and AlphaZero won 155 and lost 6. In the preprint’s own experiment from 12 human openings, AlphaZero lost 24 of 1,200 games, so it was not unbeatable.

?

How is this different from MuZero?
AlphaZero is given the rules and uses them inside its search to compute the next position and to detect and score finished games. MuZero, covered in its own explainer on this site, learns a model that predicts what matters for planning and searches inside that learned model, so it also works on Atari games whose rules it is never told. MuZero also trains its value on bootstrapped search values instead of only the final result.

Footnotes & further reading

  1. The paper: Silver, Hubert, Schrittwieser, et al., Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm (DeepMind, arXiv, December 2017). Numbers on this page are from this preprint unless marked as the 2018 version.
  2. The peer-reviewed version, with the 1,000-game rerun: Silver et al., A general reinforcement learning algorithm that masters chess, shogi, and Go through self-play (Science 362, 2018).
  3. The source of the search, network and training settings: Silver et al., Mastering the game of Go without human knowledge (AlphaGo Zero, Nature 550, 2017); the formulas quoted here are from its Methods.
  4. The independent expert/apprentice formulation: Anthony, Tian, Barber, Thinking Fast and Slow with Deep Learning and Tree Search (Expert Iteration, NeurIPS 2017), demonstrated on Hex.
  5. PUCT traces to Christopher Rosin, Multi-armed bandits with episode context (2011); the Type A / Type B framing to Claude Shannon, "Programming a Computer for Playing Chess" (1950).
  6. The successor that learns its own model of the game: the MuZero explainer on this site. For the network body, see the ResNet explainer.