World
Agent
Return per episode
Faint line: each episode. Bright line: 20-episode average. Dashed: best possible (value iteration, ignoring exploration).
Things to try
- Cliff walk + Q-learning vs SARSA (ε = 0.1, +100 episodes a few times each; falling costs −100 here). Q-learning learns the edge path and keeps falling in while it explores; SARSA learns to walk a row higher. Compare the average return.
- Slip chance 0.2 on Classic, then show the optimal policy: the safest route changes, not just the shortest.
- ε = 0 from a fresh brain: with no exploration it can get stuck repeating its first idea.
- γ = 0.5: the agent becomes short-sighted and distant rewards barely register.
- Build a maze and watch the values spread backward from the goal, one square at a time.
What am I looking at?
The agent keeps a table Q(square, move): its guess of the total future reward. After each step it nudges the guess toward
reward + γ · (value of where it landed). Q-learning uses the best next move; SARSA uses the move it actually takes
next (exploration included); Double Q keeps two tables so lucky noise doesn't inflate its estimates. The dashed line and the yellow arrows come from
value iteration, which cheats by knowing the rules of the world; it's the answer key the learners are trying to match.