RL Playground · learn by watching

An agent starts knowing nothing. Every step it gets a reward (−1 per move, plus a bonus or penalty at the goal and pits) and updates its estimate of how good each move is. Arrows show what it currently believes; colors show how good it thinks each square is. Edit the map, change the algorithm, and watch. Code and tests: rl-gym-from-scratch on GitHub.

World

Goal +10 Pit −10 Wall Start ▸ optimal move (when shown)
Tap a tool, then tap squares:

Agent

0episodes
–avg return (last 50)
–greedy success
–moves = optimal

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.