Skip to content
BIASED

Games and Monte Carlo tree search

Minimax, alpha–beta, MCTS/UCT and learned search (AlphaGo, AlphaZero, MuZero).

From MDPs to an adversary

Markov decision processes treated the next state as chance: an average over PP. In a game, much of what happens next is chosen by an opponent whose goal is the opposite of ours. Averaging over their moves is a mistake. Games also break value iteration’s other assumption — that every state can be listed. Chess and Go have far more positions than a sweep could ever visit. Search forward from the current position instead.

Take a MAX root over three MIN replies with leaf values (4,7,5)(4,7,5), (2,9,6)(2,9,6), (8,3,1)(8,3,1). Against random MIN the averages are 5.335.33, 5.675.67, 44, so the second move looks best. An adversary answers it with 22. The first move guarantees 44.

Minimax

Key idea. Value a position by the opponent’s best reply: the minimax value,

Minimax(s)={U(s)if terminal,max⁡aMinimax(Result(s,a))if MAX to move,min⁡aMinimax(Result(s,a))if MIN to move.\mathrm{Minimax}(s)=\begin{cases} U(s) & \text{if terminal},\\ \max_a \mathrm{Minimax}(\mathrm{Result}(s,a)) & \text{if MAX to move},\\ \min_a \mathrm{Minimax}(\mathrm{Result}(s,a)) & \text{if MIN to move}. \end{cases}

It is the Bellman optimality backup with expectation replaced by a minimum, and no discount because a game ends. Depth-first minimax visits every node: time O(bm)O(b^m). Tic-tac-toe from the empty board has 549,946549{,}946 nodes and value 00 (a draw). Chess at b≈35b\approx 35 and 8080 plies needs about 3580≈1012335^{80}\approx 10^{123} nodes.

Alpha–beta

Alpha–beta passes bounds α\alpha (best MAX can already force) and β\beta (best for MIN). A MIN node whose value drops to α\alpha or below is abandoned — MAX will never go there. In the three-branch tree, left-to-right search evaluates 66 of 99 leaves and still returns 44. With perfect move ordering on a uniform tree of depth dd, it evaluates

b⌈d/2⌉+b⌊d/2⌋−1b^{\lceil d/2\rceil}+b^{\lfloor d/2\rfloor}-1

leaves — about 2bd/22b^{d/2} instead of bdb^d. At b=4b=4, d=8d=8 that is 511511 against 65,53665{,}536. On tic-tac-toe, left-to-right alpha–beta visits 18,29718{,}297 nodes. Deep programs still cut off and use a hand-made evaluation; Go’s patterns defeated that approach.

The MCTS loop

Monte Carlo tree search needs no evaluation function. Each iteration: selection down the tree by a bandit rule; expansion of one untried move; simulation (random playout) to a terminal; backpropagation of the outcome along the path. After the budget, play the root move with the most visits — more robust than the highest mean.

UCT

Selection uses UCB1 / UCT:

a⋆=arg⁡max⁡a(Xˉ(s,a)+cln⁡N(s)N(s,a)).a^\star=\arg\max_a\Big(\bar X(s,a)+c\sqrt{\frac{\ln N(s)}{N(s,a)}}\Big).

Exploit the mean; explore under-visited children. With N=24N=24, children A 11/1411/14, B 1/61/6, C 0/40/4 and c=2c=\sqrt 2, the scores are 1.4601.460, 1.1961.196, 1.2611.261: A wins, and C beats B on the bonus alone. UCT converges to the minimax decision as iterations grow; on the way, averages over an exploring policy can mislead (Nim (1,3,5)(1,3,5): the winning move is found in 11/10011/100 runs after 1010 iterations, 24/10024/100 after 10001000, then 100/100100/100 after 30003000).

Toward model-free learning

A language model can later serve as prior, value or world model inside the same search pattern (Planning with language models). Every method here still assumed a model: rules, a simulator, or experience from which to learn one. Next: drop that assumption and estimate Bellman values from the rewards the agent sees one transition at a time — Q-learning and temporal-difference learning.

Check your understanding

The same questions as in Pulse. Answers are shared between modes.

Full notes

Answers are saved on the server and tied to this browser until you sign in.