Part II · Chapter 05

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.

The Quiet Magic of Updating a Guess with a Guess

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:

Pleasant Surprise

Reality beats your expectation—the road flowed faster than you thought. A green arrow pulls your hunch upward.

Unpleasant Surprise

Reality disappoints—sudden brake lights ruined the stretch. A coral arrow pulls your hunch downward.

No Surprise

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.

Interactive Lab 1 The Commute Visualizer: End-of-Trip vs. Step-by-Step

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!

25%
Trips Driven 0
Learning Style Step-by-Step (TD)
Last Event Ready to drive

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?

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.

Interactive Lab 2 The Nudge Size Tug-of-War

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.

25%
Days Observed 0
Feel Balanced · Steady & Nimble
Wobble Low
Why Not Just Shrink the Nudge to Zero?

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