Lesson 73
Monte Carlo Tree Search
Search ahead by selecting, expanding, simulating, and backing up values, guided by an exploration bonus. One example is on this page.
Intermediate12 min
What You Will Learn
- Idea
- Example
- When to use it
Idea
Monte Carlo tree search grows a tree of future actions. Selection walks toward actions with a high value plus an exploration bonus. A new leaf is expanded, a rollout estimates it, and the result is backed up to the root. The bonus shrinks as a child is visited more often.
Example
import math
parent_visits = 10
child_visits = 2
value = 0.6
bonus = 1.4 * math.sqrt(math.log(parent_visits) / child_visits)
print(f"ucb: {value + bonus:.2f}")Output:
ucb: 2.10When to use it
- Use it when you can simulate future moves, as in games.
- The score adds the child's average value to a bonus that favors less-visited moves.
- More simulations sharpen the root action. They do not replace a learned value in huge games.
Loading playground…