Part I · Chapter 01

The Learning Loop

Before any clever strategy can emerge, there is a simple rhythm: try something, watch the world answer back, and remember how it felt.

Think about how you first learned to ride a bicycle—or how you pick up a brand-new video game without ever opening the manual. Nobody hands you a sheet of exact instructions telling you how many degrees to lean your shoulders or which millisecond to press a button. Instead, you try a small move, feel the bike wobble or glide, and adjust on the very next heartbeat.

That quiet back-and-forth conversation between a decision-maker and its surroundings is the entire foundation of Reinforcement Learning. Stripped of all jargon, it is a loop with just a handful of moving parts—and once you can see the loop in motion, the rest of the field opens up naturally.

The Four Pieces of the Loop

Every reinforcement learning story has two main characters locked in a conversation: an Agent (the learner making choices) and an Environment (the world it lives in). Running between them are three kinds of glowing signals: Actions flowing out, and States plus Rewards flowing back in.

1 · The Agent

The curious decision-maker. It could be a robot arm, a game-playing program, or the glowing blue orb you are about to steer below.

2 · The World

Everything outside the agent—the board, the physics, the obstacles, and the rules that decide what happens next.

3 · Actions

The choices the agent sends into the world: step left, step right, jump over a hazard, or pause and wait.

4 · State & Reward

The world's reply: a fresh observation of what changed, paired with a reward (or sting) telling the agent how well that went.

Notice how circular this is. The agent looks at the current state, picks an action, and sends it out. The world shifts in response and sends back two things: a new state (the updated picture of the world) and a reward pulse (a quick nudge of approval, a coral jolt if something went wrong, or silence if nothing dramatic happened). Then the loop repeats.

Lab 1 · The Agent–World Loop Interactive

Send an Action from the Agent into the World—or toggle Auto-Play—and watch the luminous pulses travel around the loop. Collect the glowing green gem and leap over the coral hazard.

Steps0
Gems Collected0
Last SignalReady

Watch the glowing bar along the bottom of the lab as you play. Every positive pulse nudges the bar toward the green side; every brush with the hazard pulls it back toward coral. The agent's one overarching goal across an entire lifetime is simple to state: collect as much total reward as possible over time.

No Teacher, Only Hints

If you have heard of other kinds of machine learning, you might wonder what makes this loop so special. Why not just show the agent thousands of examples of the right move?

Learning with a Teacher

In supervised learning, a teacher holds a stack of flashcards with the exact answer written on the back. You guess "dog," and the teacher immediately replies: "Close—it was a fox. Here is the right answer."

Every mistake comes with a direct correction, and your guess never changes which flashcard shows up next.

Reinforcement Learning

In reinforcement learning, there is no answer key. The world only tells you how good your move turned out—never which move would have been better.

Even more importantly, your actions change what you see next. Stepping left puts you in a brand-new situation you might never have visited if you had stepped right.

Key Intuition · Hints, Not Instructions

A reward signal is evaluative, not instructive. If you touch a hot stove, the sting tells you that was bad—it does not hand you a recipe for cooking dinner. You have to discover better actions by trying them yourself.

The Credit Assignment Problem

In Lab 1, life was generous: the exact instant you landed on a gem, a bright green pulse fired. You never had to wonder which action earned the prize.

Real life is rarely that polite. Suppose you play a 30-move game of chess and finally checkmate your opponent on move 30. Only at the very end does the reward arrive: you won! Now pause and ask a surprisingly tricky question:

Which of your 30 moves actually deserved the credit?

Maybe move 11 quietly trapped your opponent's queen, and move 29 was just a formality—or maybe move 6 was actually a blunder that you got lucky to survive! Because the reward arrived only at the very end, it arrives as one single lump sum with no note attached explaining which earlier choices caused it.

In reinforcement learning, this is called the Credit Assignment Problem. The longer the delay between a crucial decision and its eventual payoff, the harder it becomes to trace credit—or blame—back to the step that truly mattered.

You can feel this difference directly in the puzzle below. An agent must cross a 6-stone path to reach a treasure chest. One of the six stones hides a secret switch that unlocks the chest—visible to you, but hidden from the agent. Compare how fast the agent figures out which stone matters when it gets instant breadcrumbs versus when it only hears from the chest at the very end.

Lab 2 · The Delayed Reward Puzzle Credit Assignment

On each attempt, the Agent walks across 6 stepping stones, pressing a few along the way. Watch the credit wave ripple backward from the chest—and compare how quickly the bars below pinpoint the secret key stone in each mode.

Attempts0
Chests Opened0 / 0
Agent's Top GuessUncertain

Try switching to Reward Only at the End and clicking Run 1 Attempt. The first time the chest pops open, watch that green wave sweep backward across every stone the agent happened to press on that run. All of them rise together—even the innocent bystanders! Only after several more attempts, comparing winning combinations against locked chests, do the decoy stones fade away so the true key stone can stand tall.

Why This Matters for the Rest of the Book

Almost every clever idea we will meet in later chapters—looking ahead, flowing value backward through a maze, and learning from partial stories—is really a way of solving this exact puzzle: helping an agent connect today's quiet choice to tomorrow's distant reward.

Key Takeaways

Up next: once an agent discovers one action that feels pretty good, should it keep repeating it forever—or risk trying something unknown? That tension is the heart of Chapter 2: Explore vs. Exploit.