Purpose: The selection rule that makes Monte Carlo Tree Search work. It treats every nodeβs children as a multi-armed bandit problem and applies the UCB1 formula (Kocsis and SzepesvΓ‘ri, 2006).
The Formula
At a node with visits, choose the child maximising
where is the total value backed up through child , its visit count, and the exploration constant. With rewards normalised to , the theoretically motivated value is ; in practice it is tuned per game, typically in .
Unvisited children have and are given infinite priority, so every child is tried at least once.
Node* bestUCT(Node* p, double C) {
Node* best = nullptr; double bestVal = -1e18;
double logN = log((double)p->N);
for (Node* c : p->children) {
double val = (c->N == 0) ? 1e18
: c->W / c->N + C * sqrt(logN / c->N);
if (val > bestVal) { bestVal = val; best = c; }
}
return best;
}The Bandit Connection
The multi-armed bandit problem: slot machines with unknown payout distributions; minimise regret β the gap between your total reward and always pulling the best arm.
UCB1 achieves regret, which is optimal up to constants. The confidence term is a Chernoff-Hoeffding upper confidence bound on the true mean: it shrinks as an arm is sampled more, so under-sampled arms keep getting revisited, but only until the evidence is strong enough.
UCTβs contribution is the observation that a game tree is a recursive bandit problem β each node is a bandit whose armsβ payoffs are themselves determined by bandits below. Kocsis and SzepesvΓ‘ri proved the value estimates converge to minimax, with the probability of choosing a suboptimal move at the root decreasing to zero.
Tuning
| Behaviour | |
|---|---|
| pure greedy β locks onto the first line that looks good, often badly wrong | |
| small (0.2-0.7) | exploitative; good when rollouts are informative and the tree is deep |
| theoretical default for rewards | |
| large (> 2) | nearly uniform search; wastes budget |
Tune it empirically against a fixed opponent. It matters more than most other MCTS parameters.
Variants worth knowing
- PUCT (predictor UCT) β used by AlphaGo/AlphaZero:
where is a neural-network prior over moves. The prior replaces uniform exploration, which is most of why AlphaZero searches so few nodes. - UCB1-Tuned β uses the empirical variance in the bound; usually stronger than plain UCB1.
- RAVE / AMAF β blends the UCT value with an βall moves as firstβ statistic, weighted by confidence; a large early-search speedup.
- Progressive bias β add a decaying heuristic term to guide early exploration.
Beyond games
The exploration-exploitation trade-off UCT formalises appears far outside game playing:
- A/B testing and online advertising β the original bandit application
- Hyperparameter search β successive halving and Hyperband are bandit algorithms
- Heuristic contest problems β UCT-style selection over neighbourhood moves is a reasonable alternative to simulated annealing
- Monte Carlo planning in MDPs and reinforcement learning
Variants / Use Cases
- Monte Carlo Tree Search β the algorithm UCT is the heart of
- Simulated Annealing β the other main randomized search for heuristic problems
- Randomized / Approximation β the branch overview
- Game Theory β the branch overview