Skip to content
StackDecode
AI & ML Atlas
Artificial IntelligenceReinforcement LearningalgorithmInteractive simulation

Monte Carlo Tree Search (MCTS)

Grows a search tree guided by random playouts and a bandit-style selection rule.

The idea

Instead of scoring positions with a hand-made evaluation, MCTS plays random games to the end and records who won. Moves that win more are explored more, using UCB to balance trying promising moves against trying neglected ones. AlphaGo replaced the random playouts with neural networks.

UCB = w/n + c·√(ln N / n)

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

  • current path
  • tried
  • not tried yet

Each node shows wins/visits. All empty to start. MCTS repeats four phases: select, expand, simulate, back up.

iterations:
0
root visits:
0
1/40

The true win rates are hidden from the algorithm; it discovers the best move only by sampling.

Step by step

  1. 1Selection: walk down the tree choosing children with the best UCB score.
  2. 2Expansion: add a new child node.
  3. 3Simulation: play out to the end of the game (a rollout).
  4. 4Backpropagation: add the result to every node on the path.
  5. 5Repeat thousands of times, then play the most-visited move.

Where it is used

Go, general game playing, planning under uncertainty.

Watch out for

Random rollouts can be a poor guide in tactical games; branching factor still matters.

Related