A corridor has three non-terminal cells 1, 2, 3 in a row, with a terminal cell L to the left of cell 1 and a terminal cell R to the right of cell 3. The policy moves left or right with probability 0.5 each. Moving into R gives reward +1, and every other move gives reward 0. With γ=1 and V0=0, compute V1,V2,V3 (synchronous sweeps) for cells 1, 2, 3. What do the values converge to?

Reinforcement learning, Dynamic programming
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can run iterative policy evaluation by hand using the Bellman expectation backup.

Key idea

Each sweep applies Vk+1(s)=∑aπ(a∣s)[r+γVk(s′)] to every state, using only the values from the previous sweep. The sweeps converge to Vπ, the solution of the Bellman expectation equations.

Steps

  1. Terminal cells have value 0. Write the three backups: Vk+1(1)=0.5⋅0+0.5 Vk(2), Vk+1(2)=0.5 Vk(1)+0.5 Vk(3), and Vk+1(3)=0.5 Vk(2)+0.5 (1+0).
  2. Sweep 1 (from all zeros): V1=(0, 0, 0.5). Only cell 3 sees the reward.
  3. Sweep 2: V2(1)=0.5×0=0, V2(2)=0.5×0+0.5×0.5=0.25, V2(3)=0.5×0+0.5=0.5.
  4. Sweep 3: V3(1)=0.5×0.25=0.125, V3(2)=0.5×0+0.5×0.5=0.25, V3(3)=0.5×0.25+0.5=0.625.
  5. Find the limit by solving the fixed-point equations. Substituting V(1)=V(2)/2 and V(3)=V(2)/2+1/2 into V(2)=12(V(1)+V(3)) gives V(2)=12(V(2)+12), so V(2)=0.5. Then V(1)=0.25 and V(3)=0.75.
  6. Interpret: Vπ(s) is the probability that a random walk started at s reaches R before L.

Common mistakes

How long your answer should be

A short table of three sweeps, then the limit; about 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: In state s the agent takes action a with Q(s,a)=1, gets reward 0 and lands in s′, where Q(s′,a1)=3 and Q(s′,a2)=5. The ε-greedy policy then picks the exploratory action a1. With α=0.5 and γ=0.9, compute the new Q(s,a) under SARSA and under Q-learning. Why do they differ?
Next in Reinforcement learning: After t=10 total pulls, a three-armed bandit with rewards in [0,1] has pull counts n=(5,3,2) and sample means μ^=(0.6,0.5,0.4). Which arm does UCB1 pull next, using the index μ^i+2ln⁡t/ni? What would a greedy agent do?