Skip to main content
This section implements value iteration for the classic 4×3 gridworld example in Artificial Intelligence: A Modern Approach, Figure 17.2. It mirrors the policy iteration page on the same MDP so you can compare the two algorithms side by side.
  • Terminal states: +1 at (3,0), -1 at (3,1)
  • Wall: (1,1)
  • Step cost: -0.04
  • Discount factor γ = 1.0
Value iteration interleaves the Bellman expectation backup with a max over actions in a single update: vk+1(s)=maxasP(ss,a)(r(s,a,s)+γvk(s))v_{k+1}(s) = \max_a \sum_{s'} P(s' \mid s, a)\,\bigl(r(s, a, s') + \gamma\, v_k(s')\bigr) After convergence the optimal policy is recovered greedily as π(s)=argmaxasP(ss,a)(r+γv(s))\pi^*(s) = \arg\max_a \sum_{s'} P(s' \mid s, a)(r + \gamma\, v^*(s')).
Value iteration optimal policy on the 4×3 gridworld Optimal policy and converged value function from value iteration. Compare with the policy iteration page, both algorithms reach the same π\pi^* and the same vv^* on this MDP.