In the cliff-walking gridworld (reward −1 per step, −100 for stepping off the cliff), an ε-greedy SARSA agent learns a safe path away from the edge, while Q-learning learns the path along the edge yet earns less reward per episode during training. Why?

Reinforcement learning, Temporal-difference learning
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you understand the practical consequence of on-policy versus off-policy targets when exploration is never switched off.

Key idea

SARSA's target r+γQ(s′,a′) uses the next ε-greedy action, so it learns Qπε, the value of the exploring policy, which includes the risk of random steps off the cliff. Q-learning's target r+γmax⁡a′Q(s′,a′) learns Q∗, the value of acting greedily afterwards, which ignores that risk.

Steps

  1. Write both updates side by side and point to the only difference: Q(s′,a′) with a′∼πε versus max⁡a′Q(s′,a′). Here πε is the ε-greedy policy: it takes the best-looking action with probability 1−ε and a random action otherwise.
  2. State what each converges to with fixed ε: SARSA to Qπε, Q-learning to Q∗.
  3. Apply it to the cliff: next to the edge, a random exploratory action can step off for −100. SARSA's values near the edge include this risk, so the longer, safer path scores higher.
  4. Q-learning's values assume greedy play afterwards, so the shortest path along the edge (13 steps on the standard 4×12 grid) is optimal. But the agent still explores while following it and sometimes falls, so its online return is worse.
  5. Conclude: if ε→0 over time, both converge to the optimal path. SARSA is preferable when mistakes made during learning are costly, as with a real robot.

Common mistakes

How long your answer should be

2–3 minutes: the two targets, one paragraph of reasoning, one sentence on decaying ε.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: Compare Monte Carlo and TD(0) value estimation in terms of bias and variance. Given eight episodes, one (A, 0, B, 0), six (B, 1) and one (B, 0), with γ=1, what do batch Monte Carlo and batch TD(0) give for V(A) and V(B)?
Next in Reinforcement learning: Write PPO's clipped surrogate objective. With ϵ=0.2, evaluate the per-sample objective, and say whether it has a non-zero gradient, when (a) A=+1, r=1.5; (b) A=−1, r=0.5; (c) A=−1, r=1.5. What is the clipping for?