Log inStart free
LESSON 13.06 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Monte Carlo tree search and UCT

Watch a search tree grow one simulation at a time toward the winning move.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 13.06 · SEARCH BAYSIM 8 · TAKE 2 · U 2.13
01
Stage 1 of 6 · Select
Seven simulations built this tree. Simulation 8 follows the highest UCT score U down to 7 stones.
Explain it simply

Each circle is a position, with the stones left inside. The search starts at the top. At each fork, it adds a bonus to each move's win rate Q. The bonus is bigger for moves tried less often, so no move is forgotten. The search takes the move with the highest sum, U.

A tree of 8 positions after 7 simulations. At the root, U is 1.79 for take 1, 2.13 for take 2, 1.95 for take 3. The ochre path goes down to 7 stones.

wins W over visits NUCT path, value tablenew node, rollout
A to moveB to moveA to moveB to move9N 782/3U 1.7973/3U 2.1360/1U 1.9570/160/161/150/1take 1: U = 0.67 + 1.4·√(ln 7 / 3) = 1.79take 2: U = 1.00 + 1.4·√(ln 7 / 3) = 2.13 ← highesttake 3: U = 0.00 + 1.4·√(ln 7 / 1) = 1.95simulation 8: selecttake 1take 2take 3A to moveB to moveA to moveB to move9N 782/3U 1.7973/3U 2.1360/1U 1.9570/160/161/150/1take 1: U = 0.67 + 1.4·√(ln 7 / 3) = 1.79take 2: U = 1.00 + 1.4·√(ln 7 / 3) = 2.13 ← highesttake 3: U = 0.00 + 1.4·√(ln 7 / 1) = 1.95simulation 8: selecttake 1take 2take 3
Toy: Nim with 9 stones, a value table from 200 self-play games
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
U=Q+cln⁡Nn\sy{U}{ink}{U} = \sy{Q}{out}{Q} + \sy{c}{param}{c}\sqrt{\frac{\ln \sy{N}{ink}{N}}{\sy{n}{ink}{n}}}
Utake 2=1.00+1.4ln⁡7/3=2.13U_{\text{take } 2} = 1.00 + 1.4\sqrt{\ln 7 / 3} = 2.13

Win rate plus a bonus that shrinks as a move gets more visits.

Common mix-ups

MYTHAlways following the best win rate finds the best move.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With random rollouts and c at 0, does the search play take 1?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.