Log inStart free
LESSON 15.18 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Value iteration and Bellman contraction

Watch value iteration sweep a gridworld until two different starts agree.


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.18 · VALUE BAYSLIP 20% · MOVE −0.04 · γ 0.90
01
Stage 1 of 6 · The gridworld
A move costs 0.04 and slips sideways with chance 20%. The goal pays 1, the pit costs 1, and both end the episode.
Explain it simply

This is a small world that the code knows completely, every reward and every chance. The arrows show one move up. It goes up 80% of the time and slides to each side 10% of the time. Value iteration uses this full model, so it never has to play a single game.

A 4 by 4 grid. The goal is top right, the pit is under it, and the wall is in row 2. The start is bottom left. A move up from row 2, column 3 goes up with chance 80%.

value above 0, resultvalue below 0, gap, errormove chances, γ, stop linescell
goal+1pit−1start80%10%10%each move −0.04enter the goal +1, the episode endsenter the pit −1, the episode endsslip chance 0.2: 0.1 to each sidethe gridworldgoal+1pit−1start80%10%10%each move −0.04enter the goal +1, the episode endsenter the pit −1, the episode endsslip chance 0.2: 0.1 to each sidethe gridworld
Toy: 4×4 gridworld, 1 goal, 1 pit, 1 wall
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
P(chosen way)=1−q,P(each side)=q/2\sy{p}{param}{P}(\text{chosen way}) = 1 - \sy{q}{param}{q}, \quad \sy{p}{param}{P}(\text{each side}) = \sy{q}{param}{q}/2
P(chosen way)=1−0.2=0.8,P(each side)=0.1P(\text{chosen way}) = 1 - 0.2 = 0.8, \quad P(\text{each side}) = 0.1

A move goes the chosen way or slips to a side.

Common mix-ups

MYTHA tiny change per sweep means the values are right.

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

Predict, then reveal
3 CHECKS · PRO
Q01With a slip chance of 0.2, if γ goes from 0.9 to 0.95, do more or fewer sweeps run?

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.