Skip to content

Model-Based RL and Planning: Dyna, MCTS and AlphaZero

TL;DR

A model of the environment predicts what happens next: given a state and an action, it returns the next state and the reward. An agent that has a model can plan: it can try things out in its head instead of in the real world. Dyna-Q learns a model from its own experience and uses it to replay imagined steps, so it needs far fewer real steps. Monte Carlo Tree Search (MCTS) plans at the moment of choosing a move, by growing a search tree of possible futures. AlphaZero guides that search with a neural network trained by self-play, and MuZero even learns the model itself.

Level: intermediate · Prerequisites: Q-learning & SARSA, Actor-critic. The UCB rule from Multi-armed bandits comes back in Step 5.


Why should I care?

Every method so far in this series was model-free. Q-learning, DQN, policy gradients and actor-critic all learn what to do straight from experience, and they need a lot of it. The original DQN trained on 50 million frames per Atari game, roughly 38 days of non-stop play for a human.

Real experience is often expensive or slow: a robot wears out, a chemistry experiment takes a day, a patient cannot be used for trial and error. People don't learn like that either. Before you cross a busy road, you imagine what would happen if you stepped out now. That imagined experience is free.

Model-based RL gives agents the same ability. It is behind some of RL's biggest successes:

  • AlphaGo beat Go world champion Lee Sedol in 2016, and AlphaZero (2017) beat the strongest chess, shogi and Go programs. Both search ahead, using the game's rules as the model.
  • MuZero (2019) reached the same level without being told the rules, by learning its own model, and also mastered Atari.
  • Planning with learned models is how many robot-control systems squeeze good behaviour out of a few hours of real data.

Step 1 — What is a model?

In the first lesson the environment was a black box: you send an action, it sends back a reward and a next state. A model is the agent's own copy of that black box. It answers the question "if I am in state \(s\) and take action \(a\), what happens?"

\[ \text{model}(s, a) \;\to\; \hat{p}(s', r \mid s, a) \]

The hat on \(\hat p\) means "estimated": the model is the agent's belief about the true dynamics \(p(s', r \mid s, a)\) from the MDP lesson. There are two kinds:

Distribution model Sample model
What it gives all outcomes with their probabilities one random outcome, like a dice roll
Example "80% → next cell, 10% → slide up, 10% → slide into the cliff" "this time you slid up"
Used by dynamic programming (it sums over all outcomes) Dyna, MCTS (they just need samples)

And two places a model can come from:

  • Given: the rules are known exactly. Board games, physics simulators, the cliff world when we read its code.
  • Learned: the agent builds it from its own experience. That is what Dyna (Step 3) and MuZero (Step 6) do.

With a model, the agent can do planning: compute or improve a policy using imagined experience instead of real experience. Dynamic programming was already planning: value iteration loops over the model's probabilities and never touches the real environment. The new question in this lesson is how to plan when the model has to be learned, or when the state space is far too big to sweep through.

What to notice

Model-free agents learn what to do (Q-values or a policy). Model-based agents also learn how the world works, and then work out what to do. The second kind of knowledge can be reused: if the goal moves, a model of the walls and the cliff is still correct.


Step 2 — Learning a model by counting

In a small, discrete world, learning a model is just counting. Every time the agent takes action \(a\) in state \(s\) and sees reward \(r\) and next state \(s'\), it adds one to a counter \(n(s, a, s', r)\). The estimated probability of an outcome is how often it happened:

\[ \hat{p}(s', r \mid s, a) = \frac{n(s, a, s', r)}{n(s, a)} \]

where \(n(s, a)\) is how often the agent tried \(a\) in \(s\) at all. This is the same "average of what you saw" idea as the Monte Carlo value estimates, applied to outcomes instead of returns.

Here is what that looks like on the slippery cliff world (slip chance 0.2), for one state-action pair: standing at row 2, column 1 (just above the cliff) and moving right. The true answer is 80% to the next cell, 10% sliding up and 10% sliding down into the cliff, an expected reward of \(0.9 \cdot (-1) + 0.1 \cdot (-20) = -2.9\).

Tries \(n(s, a)\) → next cell (−1) ↑ slide up (−1) ↓ into the cliff (−20) estimated expected reward
10 10 (1.00) 0 (0.00) 0 (0.00) −1.00
100 86 (0.86) 6 (0.06) 8 (0.08) −2.52
1000 779 (0.78) 104 (0.10) 117 (0.12) −3.22
true 0.80 0.10 0.10 −2.90

What to notice

  • After 10 tries the model has never seen a slip, so it believes that walking along the cliff edge is perfectly safe. A planner that trusts this model will happily plan routes along the edge. Small amounts of data give confident, wrong models.
  • With more data the counts approach the true probabilities. In a deterministic world (slip 0), a single try per state-action pair gives the exact model.
  • For big or continuous state spaces (images, robot joints) you can't count. You train a neural network \(\hat f_\phi(s, a) \to (\hat s', \hat r)\) by supervised learning on the agent's transitions instead. The idea stays the same.

Step 3 — Dyna-Q: learn, model, plan

Dyna (Sutton, 1990) is the simplest way to mix the two worlds. It is plain Q-learning with one addition. After every real step, the agent:

  1. updates \(Q\) from the real transition, exactly as Q-learning does (direct RL),
  2. records the transition in its model (model learning),
  3. then performs \(n\) extra Q-learning updates on transitions imagined by the model (planning).

Each planning update picks a state-action pair \((s, a)\) the agent has already tried, asks the model for an outcome \((r, s')\), and applies the usual update:

\[ Q(s, a) \leftarrow Q(s, a) + \alpha \big[\, r + \gamma \max_{a'} Q(s', a') - Q(s, a) \,\big] \]

That's all. Real and imagined experience go through the same update rule; the model is just a free source of extra experience.

Try it: below is one Dyna-Q agent on the (non-slippery) cliff world from lesson 1, with \(\alpha = 0.1\), \(\gamma = 0.95\), \(\varepsilon = 0.1\) and all Q-values starting at 0. Pick \(n\), then run one episode at a time. The orange ticks are the model: one tick on the side of a cell for each action the agent has tried there.

🎚️ Interactive: inside a Dyna-Q agent

What to notice

  • The first episode is a stumble for every n. The model starts empty and the agent has no idea where the goal is, so the first episode usually ends in the cliff after a few random steps.
  • Planning spreads news backwards. Each real step changes one Q-value. Each planning step can update any pair the model knows, so the +10 of the goal travels back along known paths without the agent walking them again. Compare the green cells after 10 episodes with n = 0 and with n = 50: over 100 Python runs, the median number of cells with a positive value was 1 for n = 0, 3 for n = 5 and 8 for n = 50.
  • The model fills up fast. After a few episodes most cells have ticks on all four sides. In this deterministic world one visit is enough to know an outcome exactly.
  • Watch the dashed green line. With n = 50 the greedy route usually becomes the optimal 7-step path along the cliff edge within a handful of episodes. With n = 0 it takes dozens.

Step 4 — How much does planning buy?

One episode is noisy. To compare fairly, we run many independent agents for each value of \(n\) and ask: after how many episodes is the greedy route the optimal 7-step route? The widget runs 50 agents per curve right in your browser.

📈 Interactive: Dyna-Q learning curves for different n

The Python version of the same experiment (the code is in Putting it all together), with 100 runs per setting, gives:

planning steps \(n\) median episodes until the optimal route runs on it after 10 episodes median real steps until the optimal route
0 (plain Q-learning) 32 0% about 840
5 10 34% 211
50 7 84% 129

What to notice

  • Planning is a trade. With \(n = 50\) the agent needs about 6× fewer real steps than plain Q-learning, but it does 50 extra updates per real step. Dyna pays with computation (cheap) to save experience (expensive).
  • Returns diminish. Going from 0 to 5 helps more than going from 5 to 50. Once the model has been replayed enough for the Q-values to settle, more planning adds little. Try your own \(n\) with the slider.
  • Look closely at n = 50 late on. Its curve flattens a little below 100%. In the Python runs, 5 of the 100 agents with \(n = 50\) were still on a 9-step route after 60 episodes. That's a real weakness of planning with a learned model, and Step 7 explains it.

Dyna and the replay buffer

The DQN replay buffer is close to Dyna: it stores real transitions and replays them for extra updates. A replay buffer is a non-parametric model that can only replay exactly what happened. A real model can also answer questions about state-action pairs in new combinations, and (if it is a network) generalise to states it has never seen.


Dyna plans in the background: it improves a Q-table for all states, whenever it has spare time. A different style is to plan at decision time: when you have to move now, focus all your thinking on the current state and the futures that can follow from it. That is what chess players do.

The obvious way is a search tree: the current state is the root, each legal move is a branch, each reply is a branch below that, and so on. For tic-tac-toe you could search the whole tree. For Go there are about \(10^{170}\) positions, so you must be selective. Monte Carlo Tree Search (MCTS) grows the tree one path at a time, spending more effort on moves that look promising. Every node stores two numbers: a visit count \(N\) and a total value \(W\), so its average value is \(Q = W / N\).

Each simulation has four phases:

The selection rule is the heart of MCTS. At each node it treats the children like the arms of a multi-armed bandit and uses the UCB rule, which in a tree is called UCT (Upper Confidence bounds applied to Trees):

\[ \text{UCT}(\text{child}) = \underbrace{\frac{W}{N}}_{\text{exploit: average result}} + \underbrace{c \sqrt{\frac{\ln N_{\text{parent}}}{N}}}_{\text{explore: bonus for few visits}} \]

The first term favours moves that have worked well. The second is large for moves that have hardly been tried, and shrinks as \(N\) grows. With \(c = \sqrt 2\) this balances exploring and exploiting in the same way as UCB does for bandits.

Try it: X to move in the position at the top. One move wins by force; the others don't. Press Next phase a few times to watch single simulations, then +10 and +100 to see where the visits go.

🌳 Interactive: Monte Carlo Tree Search, step by step

What to notice

  • The winning move is "left". It makes two threats at once (the left column and the middle row), and O can only block one. Exact minimax search agrees: left is a win (+1), top-left, top and centre are draws (0), and bottom loses (−1).
  • Early on, random play-outs mislead. In our Python run with seed 0, after 25 simulations MCTS preferred top-left (7 visits) and even rated the losing move bottom at +0.25: random opponents don't punish mistakes. After 100 simulations it preferred centre.
  • Then the tree takes over. As the tree grows deeper below left, the search sees that every O reply loses. In the same run, left had 80% of the visits after 400 simulations (\(Q = +0.91\)) and 91% after 1000.
  • More thinking, better moves. Over 100 Python runs with different seeds, MCTS chose left in 23 runs with K = 25, 36 with K = 50, 67 with K = 100, 97 with K = 200 and all 100 with K = 400.
  • Watch the UCT column. Moves with few visits get a large bonus, so even bad moves are re-checked now and then. The bonus is why the search keeps looking at left long enough to discover it is winning.

Step 6 — AlphaGo, AlphaZero and MuZero: search + deep learning

Random play-outs are a weak judge of a position, and in Go a game lasts 200+ moves, so a random play-out tells you almost nothing. The AlphaGo family made MCTS strong by adding a neural network \(f_\theta(s) = (\mathbf{p}, v)\) with two heads:

  • a policy head \(\mathbf{p}\): prior probabilities for each move, "which moves would a strong player consider?"
  • a value head \(v\): a prediction of the final result from this position, like the critic in actor-critic.

The network changes two phases of MCTS:

  1. Selection uses the prior \(P(s, a)\) from the policy head, so the search mostly looks at moves the network likes (the PUCT rule): $$ \text{score}(s, a) = Q(s, a) + c\, P(s, a)\, \frac{\sqrt{N(s)}}{1 + N(s, a)} $$
  2. Simulation is dropped. Instead of a random play-out, the new leaf is scored by the value head \(v\). One network call replaces hundreds of random moves.

How is the network trained? By self-play: the agent plays games against itself, choosing each move with MCTS. The search makes the agent stronger than its raw network, so the search results are better training targets than the network's own outputs:

This is a form of policy iteration (from the dynamic programming lesson): MCTS is the policy improvement step, and training the network to imitate it makes the improvement permanent.

The family in short:

System Model used for search Network trained from Games
AlphaGo (2016) the game rules human expert games, then self-play Go
AlphaGo Zero (2017) the game rules self-play only, no human data Go
AlphaZero (2017) the game rules self-play only Go, chess, shogi
MuZero (2019) a learned model self-play and real experience Go, chess, shogi, Atari

MuZero goes one step further. It doesn't get the rules. It learns three networks: a representation that turns the observation into a hidden state, a dynamics network that predicts the next hidden state and reward from a hidden state and an action (the learned model), and the same prediction network for \(\mathbf{p}\) and \(v\). MCTS then searches entirely inside the learned hidden space. The learned model never has to reconstruct the screen or the board; it only has to predict what matters for planning: rewards, values and policies.

What to notice

The network alone is like fast intuition; MCTS is slow deliberate thinking that checks the intuition. Training on the search results turns slow thinking into better intuition, and the loop repeats.


Step 7 — When the model is wrong

A model is only useful if it is right where the planner looks. Three things go wrong in practice:

  • Errors compound. A one-step model that is a little off feeds its own prediction back in as the next state, so mistakes add up over a long imagined trajectory. If each predicted step is right with probability 0.95, a 10-step imagined rollout is entirely right with probability \(0.95^{10} \approx 0.60\), and a 50-step one only \(0.95^{50} \approx 0.08\). This is why methods such as MBPO (model-based policy optimisation) only imagine short rollouts branching off real states.
  • The planner exploits model errors. A planner searches for the action with the best predicted outcome. If the model is wrong somewhere in a flattering way, that is exactly where the planner will go, like the 10-try model in Step 2 that thought the cliff edge was perfectly safe.
  • The model only knows what you tried. Dyna-Q's planning only replays state-action pairs it has seen. In all 5 stuck runs from Step 4, the agent had never tried moving right from one or two cells near the end of the cliff edge, so its model knew nothing there and the planner kept polishing a 9-step detour that it did know. Dyna-Q+ fixes this with a small exploration bonus for state-action pairs not tried for a long time.

Model-based or model-free?

Model-based methods use data far more efficiently and can reuse a model for new goals. Model-free methods are simpler and don't suffer from model bias: their errors come only from noise. Many modern systems combine both, as Dyna does: plan where the model is trusted, learn directly from real experience everywhere.


Putting it all together

Here is Dyna-Q on the cliff world in plain Python, with the model as a table of counts. Set n_planning = 0 and it is ordinary Q-learning:

import random
from statistics import mean, median

MAP = ["......",
       "..#...",
       "......",
       "SCCCCG"]
MOVES = [(-1, 0), (0, 1), (1, 0), (0, -1)]          # up, right, down, left
START = (3, 0)


def env_step(s, a):
    """The real environment (the agent does NOT get to read this code)."""
    r, c = s[0] + MOVES[a][0], s[1] + MOVES[a][1]
    if not (0 <= r < 4 and 0 <= c < 6) or MAP[r][c] == "#":
        r, c = s                                      # bumped a wall or edge: stay put
    tile = MAP[r][c]
    if tile == "G":
        return (r, c), +10, True
    if tile == "C":
        return (r, c), -20, True
    return (r, c), -1, False


def greedy(Q, s, rng):
    best = max(Q[s])
    return rng.choice([a for a in range(4) if Q[s][a] == best])   # break ties at random


def dyna_q(n_planning, episodes=60, alpha=0.1, gamma=0.95, eps=0.1, seed=0):
    rng = random.Random(seed)
    Q = {(r, c): [0.0] * 4 for r in range(4) for c in range(6)}
    model = {}                       # (s, a) -> {(s', r, done): how often we saw it}
    history = []                     # after each episode: is the greedy route the 7-step one?

    def q_update(s, a, r, s2, done):
        target = r if done else r + gamma * max(Q[s2])
        Q[s][a] += alpha * (target - Q[s][a])

    for _ in range(episodes):
        s, done, t = START, False, 0
        while not done and t < 1000:
            # 1. act in the REAL world (ε-greedy) and learn from it: plain Q-learning
            a = rng.randrange(4) if rng.random() < eps else greedy(Q, s, rng)
            s2, r, done = env_step(s, a)
            q_update(s, a, r, s2, done)
            # 2. learn the MODEL: count what happened
            counts = model.setdefault((s, a), {})
            counts[(s2, r, done)] = counts.get((s2, r, done), 0) + 1
            # 3. PLAN: n extra Q-learning updates on experience imagined by the model
            seen = list(model)
            for _ in range(n_planning):
                ps, pa = rng.choice(seen)                       # a state-action we have tried
                outcomes = model[(ps, pa)]
                (ps2, pr, pdone), = rng.choices(list(outcomes), weights=list(outcomes.values()))
                q_update(ps, pa, pr, ps2, pdone)
            s, t = s2, t + 1
        history.append(greedy_route_length(Q) == 7)
    return history


def greedy_route_length(Q):
    """Follow the greedy policy (no exploration) from the start; return its number of steps."""
    s = START
    for t in range(1, 30):
        s, r, done = env_step(s, Q[s].index(max(Q[s])))
        if done:
            return t if r > 0 else None
    return None


for n in [0, 5, 50]:
    runs = [dyna_q(n, seed=seed) for seed in range(100)]
    first = [h.index(True) + 1 if True in h else 61 for h in runs]
    print(f"n = {n:2d}: optimal route found after {median(first):4.1f} episodes (median of 100 runs); "
          f"runs on it after 10 episodes: {mean(h[9] for h in runs):.0%}, after 60: {mean(h[-1] for h in runs):.0%}")
n =  0: optimal route found after 32.0 episodes (median of 100 runs); runs on it after 10 episodes: 0%, after 60: 100%
n =  5: optimal route found after 10.0 episodes (median of 100 runs); runs on it after 10 episodes: 34%, after 60: 100%
n = 50: optimal route found after  7.0 episodes (median of 100 runs); runs on it after 10 episodes: 84%, after 60: 95%

And a compact MCTS for tic-tac-toe. The "model" is just the rules (play, moves, winner); minimax checks the answer by searching the whole game tree:

import math
import random

LINES = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), (0, 4, 8), (2, 4, 6)]
NAMES = ["top-left", "top", "top-right", "left", "centre", "right", "bottom-left", "bottom", "bottom-right"]


# ---- The model: the rules of tic-tac-toe. A board is a 9-character string like "..O..XX.O".
def winner(b):
    for i, j, k in LINES:
        if b[i] != "." and b[i] == b[j] == b[k]:
            return b[i]
    return None

def to_move(b):
    return "X" if b.count("X") == b.count("O") else "O"

def moves(b):
    return [] if winner(b) else [i for i in range(9) if b[i] == "."]

def play(b, i):
    return b[:i] + to_move(b) + b[i + 1:]


class Node:
    def __init__(self, board, parent=None, move=None):
        self.board, self.parent, self.move = board, parent, move
        self.children, self.untried = [], moves(board)
        self.N, self.W = 0, 0.0          # visit count, total value (for the player who moved INTO this node)


def uct(child, c=math.sqrt(2)):
    return child.W / child.N + c * math.sqrt(math.log(child.parent.N) / child.N)


def mcts(board, simulations, rng):
    root = Node(board)
    for _ in range(simulations):
        node = root
        # 1. Selection: walk down the tree, always taking the child with the highest UCT score
        while not node.untried and node.children:
            node = max(node.children, key=uct)
        # 2. Expansion: add one new child for a move we have never tried here
        if node.untried:
            m = node.untried.pop(rng.randrange(len(node.untried)))
            child = Node(play(node.board, m), node, m)
            node.children.append(child)
            node = child
        # 3. Simulation: play random moves until the game ends
        b = node.board
        while moves(b):
            b = play(b, rng.choice(moves(b)))
        w = winner(b)
        # 4. Backup: every node on the path gets +1 / 0 / -1 from the view of the player who moved into it
        while node:
            mover = "O" if to_move(node.board) == "X" else "X"
            node.N += 1
            node.W += 0 if w is None else (1 if w == mover else -1)
            node = node.parent
    return root


def minimax(b):
    """Exact value for the player to move (+1 win, 0 draw, -1 loss). Fine for a game this small."""
    if winner(b):
        return -1                        # the previous player just won
    if not moves(b):
        return 0
    return max(-minimax(play(b, m)) for m in moves(b))


board = "..O..XX.O"                      # X to move
print("minimax:", {NAMES[m]: -minimax(play(board, m)) for m in moves(board)})
for K in [25, 100, 400, 1000]:
    root = mcts(board, K, random.Random(0))
    best = max(root.children, key=lambda ch: ch.N)
    stats = ", ".join(f"{NAMES[ch.move]} {ch.N} ({ch.W / ch.N:+.2f})"
                      for ch in sorted(root.children, key=lambda ch: ch.move))
    print(f"K={K:4d}: plays {NAMES[best.move]:7s} share {best.N / K:4.0%} | N (W/N): {stats}")

for K in [25, 50, 100, 200, 400]:
    right = sum(max(mcts(board, K, random.Random(s)).children, key=lambda ch: ch.N).move == 3
                for s in range(100))
    print(f"K={K:3d}: picks the winning move in {right}/100 runs")
minimax: {'top-left': 0, 'top': 0, 'left': 1, 'centre': 0, 'bottom': -1}
K=  25: plays top-left share  28% | N (W/N): top-left 7 (+0.43), top 6 (+0.33), left 4 (+0.00), centre 4 (+0.00), bottom 4 (+0.25)
K= 100: plays centre  share  31% | N (W/N): top-left 21 (+0.33), top 16 (+0.25), left 20 (+0.40), centre 31 (+0.45), bottom 12 (+0.08)
K= 400: plays left    share  80% | N (W/N): top-left 21 (+0.33), top 17 (+0.24), left 319 (+0.91), centre 31 (+0.45), bottom 12 (+0.08)
K=1000: plays left    share  91% | N (W/N): top-left 23 (+0.30), top 23 (+0.26), left 907 (+0.96), centre 34 (+0.44), bottom 13 (+0.00)
K= 25: picks the winning move in 23/100 runs
K= 50: picks the winning move in 36/100 runs
K=100: picks the winning move in 67/100 runs
K=200: picks the winning move in 97/100 runs
K=400: picks the winning move in 100/100 runs

To go from here to AlphaZero, replace the random play-out with a call to a value network, add the network's prior \(P(s, a)\) to the selection score (the PUCT rule), and train the network on the visit counts and game results from self-play. Open-source versions to read: alpha-zero-general (small and readable) and DeepMind's mctx (MCTS for AlphaZero and MuZero in JAX).


Common misconceptions

\"Model-based means the agent is given the rules.\"

Sometimes it is (MCTS and AlphaZero use the game rules), but often the model is learned from experience, as in Dyna and MuZero. "Model-based" only means the agent has some model of \(p(s', r \mid s, a)\) and uses it to plan.

\"More planning is always better.\"

Planning is only as good as the model. With a learned model, extra planning can make the agent more confident in the model's mistakes, as in the stuck Dyna runs and the "safe" cliff edge of Step 2. The gain from more planning also shrinks fast (0 → 5 steps helped more than 5 → 50).

\"MCTS picks the move with the highest average value.\"

The usual choice is the most-visited child. Visits are a more robust signal: a move can have a high average from only a few lucky play-outs, but it only collects many visits if it kept looking good as the search looked deeper.

\"AlphaZero is just a very good neural network.\"

The raw network is much weaker than network + search. The search improves on the network at every move, and the network is trained to imitate those improved choices. Take the search away and both the play and the training signal get worse.


Check yourself

1. What does a model of the environment predict, and how would you learn one in a small grid world?

It predicts what happens after taking action \(a\) in state \(s\): the next state \(s'\) and the reward \(r\) (or their probabilities \(\hat p(s', r \mid s, a)\)). In a small grid world you count: every real transition adds 1 to \(n(s, a, s', r)\), and \(\hat p = n(s, a, s', r) / n(s, a)\).

2. Dyna-Q with n = 0 is which algorithm? What does n > 0 add, and what does it cost?

With \(n = 0\) it is plain Q-learning. With \(n > 0\) every real step is followed by \(n\) Q-learning updates on transitions imagined by the model. It costs extra computation per step, but it saves real experience: on the cliff world, \(n = 50\) found the optimal route after a median of 129 real steps versus about 840 for \(n = 0\).

3. In the UCT formula, what happens to a child that has been visited very few times? Why is that useful?

Its exploration bonus \(c\sqrt{\ln N_{\text{parent}} / N}\) is large, so it gets selected again even if its average looks poor. That stops the search from writing off a move after a few unlucky random play-outs. In the tic-tac-toe example, the winning move left had an average of 0.00 after 25 simulations and only became the favourite once the search kept revisiting it.

4. In AlphaZero, what are the training targets for the policy head and the value head?

The policy head is trained towards the MCTS visit-count distribution \(\pi\) at each position (what the search preferred). The value head is trained towards the final game result \(z\) (+1, 0 or −1 from the view of the player to move).

5. Why do errors in a learned model hurt more on long imagined rollouts than on short ones?

Each imagined step starts from the model's previous prediction, so errors compound. If each step is right with probability 0.95, a 10-step rollout is all correct with probability about 0.60 and a 50-step one only about 0.08. That's why methods like MBPO use short model rollouts that start from real states.


Further reading

Next lessons: Offline RL & imitation