Log inStart free
LESSON 15.C3 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Cliff walking — SARSA vs expected SARSA vs Q-learning

Watch three learners share one cliff grid and learn three different routes.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 15.C3 · CLIFF GRID4 × 12 GRID · 3 LEARNERS · SAME DRAWS
01
Stage 1 of 6 · Three learners
Three learners share the grid and the ε-greedy moves. Only the target of the update differs.
Explain it simply

You see the cliff grid from the last two lessons. Each step costs one point, and the cliff costs a hundred. Three learners train here with the same random draws, so they make the same moves until their values differ. Only one thing is different: the next value each one puts in its target.

A grid of 4 rows and 12 columns. The start is bottom left, G bottom right, and the 10 cells between them are the cliff. Under the grid, three learners: SARSA, expected SARSA and Q-learning, each with its target.

agent and routesvalues and targetsstep size α, chance πcliff, TD error
three learnersstartGthe cliff: −100 and back to starteach step: −1into the cliff: −100, back to startonto G: the episode endsSARSA (15.21)next value Q(S′, A′): the action it takes nextExpected SARSA (15.21)next value Σ π(a | S′) Q(S′, a): the average over its movesQ-learning (15.22)next value max Q(S′, a): the best next actionthree learnersstartGthe cliff: −100 and back to starteach step: −1into the cliff: −100, back to startonto G: the episode endsSARSA (15.21)next value Q(S′, A′): the action it takes nextExpected SARSA (15.21)next value Σ π(a | S′) Q(S′, a): the average over its movesQ-learning (15.22)next value max Q(S′, a): the best next action
Toy: the 4 × 12 cliff grid; values are the mean of 20 seeded runs of 500 episodes
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
y=R+γ Q^(S′)\sy{y}{out}{y} = \sy{r}{data}{R} + \gamma\,\sy{nx}{out}{\hat{Q}(S')}
γ=1,R=−1 a step,−100 for the cliff\gamma = 1, \quad R = -1 \text{ a step}, \quad -100 \text{ for the cliff}

Each target adds the reward to one next value at S′.

Common mix-ups

MYTHThe learner with the shortest route earns the most while it learns.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01At α 0.5, if ε falls to 0.01, does Q-learning still earn the least while learning?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.