Skip to main content
Open In Colab It is instructive to apply SARSA to a small, well-known environment so the learning dynamics are visible end-to-end. We use the Gymnasium CliffWalking-v1 environment described below.

Environment: CliffWalking-v1

CliffWalking-v1 is the canonical Gymnasium gridworld for tabular control. The agent moves on a 4×124 \times 12 grid: it starts at the bottom-left (state index 36) and must reach the bottom-right goal (state index 47). Every step yields reward 1-1, except stepping into any of the cells along the bottom edge between start and goal, the cliff, which yields reward 100-100 and resets the agent back to the start. The action space is Discrete(4) with the convention 0 = up, 1 = right, 2 = down, 3 = left, transitions are deterministic, and the observation is a single integer in {0,,47}\{0, \ldots, 47\} encoding row * 12 + col. With only 48 states it is small enough to learn with a plain Q-table, while also being the textbook environment (Sutton & Barto, Example 6.6) used to contrast SARSA’s safe path along the top edge against Q-learning’s optimal-but-risky path adjacent to the cliff.
Output from cell 4 Output from cell 4 Output from cell 4 Key references: (Ma & Yu, 2016; Li, 2017; Bellemare et al., 2016; Jaderberg et al., 2016; Lillicrap et al., 2015)

References

  • Bellemare, M., Srinivasan, S., Ostrovski, G., Schaul, T., Saxton, D., et al. (2016). Unifying count-based exploration and intrinsic motivation.
  • Jaderberg, M., Mnih, V., Czarnecki, W., Schaul, T., Leibo, J., et al. (2016). Reinforcement Learning with Unsupervised Auxiliary Tasks.
  • Li, Y. (2017). Deep Reinforcement Learning: An Overview.
  • Lillicrap, T., Hunt, J., Pritzel, A., Heess, N., Erez, T., et al. (2015). Continuous control with deep reinforcement learning.
  • Ma, S., Yu, J. (2016). Transition-based versus State-based Reward Functions for MDPs with Value-at-Risk.