Skip to content
StackDecode
AI & ML Atlas
Reinforcement LearningalgorithmInteractive simulation

Value Iteration

Repeatedly applies the Bellman optimality backup until the values converge.

The idea

Start with all values zero. In each sweep set V(s) = maxₐ Σ P(s′|s,a)[r + γV(s′)]. Values spread outward from rewards like a wave and converge to the optimal values V*, from which the best policy is read off greedily.

V(s) ← maxₐ Σ P(s′|s,a) [r + γ V(s′)]

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

GOAL +1PIT −1start000000000000000000
  • positive value
  • negative value
  • best action

Every state starts with value zero. A state's value is the total future reward expected from it.

sweep:
0
1/10

Each cell shows its estimated value; arrows show the action the policy would take.

Step by step

  1. 1Set V(s) = 0 for all states.
  2. 2For each state compute the best action's expected return.
  3. 3Replace V(s) with that value.
  4. 4Stop when the largest change is tiny.
  5. 5Choose the action that achieves the max in each state.

Where it is used

Small known MDPs such as grid worlds.

Watch out for

Each sweep costs O(|S|²|A|).

Related