Cliff walking
The grid has 4 rows and 12 columns. The agent starts in the bottom-left cell S, and the episode ends in the bottom-right cell G. The cells between them on the bottom row are a cliff: stepping into one gives reward and sends the agent back to S. Every other step gives reward , the moves are deterministic, and . All three agents act with an -greedy behavior policy, , and use the step size . They differ only in the value of the next state in the TD target:- SARSA uses for the next action that the -greedy policy actually takes.
- Expected SARSA uses , the expected value of the next action under the -greedy policy.
- Q-learning uses , the value under the greedy policy.
Code
Code
Code
Code
Code
Code
Maximization bias
Q-learning’s target takes the maximum of estimates. When the estimates are noisy, their maximum is biased upward, even if each estimate is unbiased. Sutton and Barto’s Example 6.7 makes this visible. Every episode starts in state A, which has two actions. Right ends the episode with reward 0. Left moves to state B with reward 0. State B has 10 actions, and each of them ends the episode with a reward drawn from a normal distribution with mean and variance 1. Left is worse than right on average, so the best -greedy policy with moves left only when exploration picks it, 5% of the time. The code runs Q-learning and Double Q-learning with and for 300 episodes, in 2,000 independent runs, and records how often each one moves left from A.Code
Code
References
- Sutton, R., Barto, A. (2018). Reinforcement Learning: An Introduction. Link
Found an error on this page? Report an issue.

