Learning from Experience
Waiting until the story ends versus updating your hunch one step at a time.
In the last chapter, we had a superpower that almost never exists in real life: a complete bird's-eye blueprint of the entire world. We could hover above the maze, see every wall and every shortcut, and let value ripple cleanly backward from the goal.
Step outside into the real world, and that blueprint vanishes. Nobody hands you a secret table telling you which highway lane flows fastest at five o'clock, which neighborhood coffee shop is worth the detour, or which chess opening will trap your opponent ten moves from now. You only discover what the world is like by walking into it, living through a slice of it, and getting surprised.
That single shift—from reading a map to learning by doing—is the heart of modern Reinforcement Learning. And surprisingly, it comes down to a choice you already make every single day.
Driving Home in Traffic
Imagine you just started a new routine commuting across town. Your route passes through five familiar landmarks: Home, the Bridge, the Highway, the Tunnel, and finally the Office. At first, you only have a rough, flat hunch about how smooth the rest of the drive feels from each spot.
Every morning is a little different. Sometimes the highway glides wide open; other mornings it snarls into a glowing sea of red brake lights. As you drive the route day after day, there are two fundamentally different ways to turn those trips into better hunches:
End-of-Trip Learning (Monte Carlo)
While you are still on the road, you keep your hunches frozen. You simply drive all the way to the destination and wait for the final verdict.
Only when you pull into the parking lot and see how the whole trip actually felt do you look back and adjust your memory of every landmark you passed along the way.
Step-by-Step Learning (Temporal Difference)
You don't wait for the trip to end! The very moment you merge onto the highway and see brake lights stacked to the horizon, you immediately update your hunch about the bridge you just left.
You update your old guess using what just happened plus your current hunch about the next landmark—learning from every single step as it unfolds.
At first glance, Step-by-Step learning sounds almost like cheating: how can you improve your hunch about the Bridge using your hunch about the Highway, when your Highway hunch might still be wrong? Because every step also mixes in a real piece of ground truth—the actual road you just drove—and the final destination is anchored in reality. Over repeated trips, truth ripples backward one surprise at a time, without ever needing a map or waiting for the finish line.
The Surprise Gap
Whether you wait until the end of the trip or update on the fly, the engine doing the actual learning is the exact same thing: Surprise.
Before you leave a landmark, you hold an expectation—a bar in your mind representing how smooth the rest of the commute looks from here. Then reality speaks. In Step-by-Step learning, reality speaks as soon as you reach the next landmark: you combine the stretch you just drove with how promising the next spot looks.
The vertical gap between what you expected and what reality just showed you is the Surprise Gap. That gap tells you both the direction and the urgency of your adjustment:
Reality beats your expectation—the road flowed faster than you thought. A green arrow pulls your hunch upward.
Reality disappoints—sudden brake lights ruined the stretch. A coral arrow pulls your hunch downward.
Reality matches your hunch almost perfectly. The arrow shrinks to zero, and your estimate settles peacefully into place.
Watch both styles of learning side by side on our five-landmark commute below. Every landmark starts with the exact same naive, flat hunch—while the faint dashed gold markers show the hidden true average smoothness of the remaining drive from each spot.
Watch the car drive from Home to the Office. Taller bars mean a smoother, happier remaining commute from that landmark. Notice how End-of-Trip (MC) waits until the car finishes before moving every bar at once, while Step-by-Step (TD) flashes a glowing Surprise Arrow and nudges the previous landmark immediately!
- Run 1 Trip in Step-by-Step (TD) mode and watch the glowing Surprise Arrow fire right as the car passes the unpredictable Highway stretch.
- Switch to End-of-Trip (MC), hit Reset, and run 1 Trip again: notice every bar stays completely frozen until the car pulls into the Office, then all four jump together.
- Hit Run 15 Trips in either mode and watch the bars settle toward the dashed gold True Average markers—even though the learner never saw the hidden traffic map!
How Big Should Each Nudge Be?
Look closely at that Nudge Size slider you just played with. It hides one of the most important trade-offs in all of learning—not just for machines, but for humans too.
Suppose your favorite stretch of highway usually flows smoothly, but one random Tuesday a stalled truck turns it into a crawl. When you feel that Surprise Gap, how much of it should you believe?
- If your Nudge Size is tiny, you barely budge. One bad day won't rattle you—which is great!—but if the city opens a real construction zone that slows traffic every single day, you will stay stubbornly behind reality for weeks.
- If your Nudge Size is twitchy, you overreact to every lucky green light and every random fender-bender. You chase yesterday's noise instead of learning the steady underlying truth.
- If your Nudge Size is balanced, you move briskly toward the true average and then hover calmly around it—steady enough to ignore one-off luck, nimble enough to adapt when the world genuinely changes.
You can feel this tug-of-war directly in the lab below. Every tick represents a new day's noisy experience on a single road. Drag the Nudge Size slider while it runs—and then click Shift Reality to simulate sudden road construction and see how quickly your hunch catches up.
On the left, watch the glowing Surprise Arrow tug your Current Hunch toward each new noisy experience. On the right, watch your hunch ribbon trace over time against the hidden True Average.
If the world never changed, shrinking your nudge size over time would eventually freeze your hunch right on the exact average. But real worlds shift—traffic patterns evolve, opponents adapt, seasons change. Keeping a gentle, steady nudge lets a learner stay forever awake to a changing world.
One Missing Piece: Choosing Which Way to Turn
Pause and appreciate how far we just came. Without any blueprint of the world, our learner can now walk through unfamiliar territory, feel surprises, and build an accurate sense of how good each place is—even before the trip is over.
There is just one catch. In our commute, there was only one road forward. Knowing that the Bridge feels better than the Highway is great for predicting your mood—but when you pull up to a fork in the road with no map, knowing how good your current spot is doesn't tell you whether to turn left or right!
In the next chapter, we solve that puzzle with one brilliant twist: instead of scoring places, we score every choice inside every place, turning each tile into a glowing compass. That idea is Q-Learning.
Key Takeaways
- No map required: Real learners rarely get a blueprint of the world—they discover value directly by living through experiences.
- End-of-Trip (Monte Carlo) vs. Step-by-Step (Temporal Difference): End-of-Trip waits for the final outcome to update every past landmark at once; Step-by-Step updates the previous landmark immediately using what just happened plus its hunch about the next spot.
- The Surprise Gap drives learning: When reality beats your expectation, nudge your hunch up; when it disappoints, nudge down; when surprise vanishes, you have learned the truth.
- Nudge Size is a tug-of-war: Too tiny makes learning painfully slow to adapt; too twitchy gets whipsawed by everyday randomness; a balanced nudge stays smooth yet responsive.