Learning Actions Directly
Skipping the map of values altogether — and learning by gently nudging good habits to happen more often.
Pause for a moment and imagine yourself standing at the free-throw line with a basketball in your hands. You bend your knees, flick your wrist, and watch the ball arc cleanly through the net.
Now ask yourself a curious question: do you calculate the exact point value of every muscle twitch before you shoot? Do you pause to score "elbow two degrees higher" versus "wrist five percent faster" in some giant mental spreadsheet?
Of course not. You try a shot, watch what happens, and adjust your habit directly. If a smooth follow-through swishes through the rim, your body quietly leans toward doing that again next time. If a flat release clanks off the front iron, your body leans away from it.
Up until now in this book, every learner we built has been an accountant of values. It painted tiles with warmth, scored every choice on a compass, and only picked an action at the very end by asking, "Which option has the highest score?" Today, we are going to flip that entire mindset upside down. What if an agent never builds a score sheet at all — and instead learns its actions directly?
A Policy as a Glowing Wheel of Habits
In reinforcement learning, an agent's strategy — its set of habits for choosing what to do — is called a policy. When we learn a policy directly, you can picture the agent's brain not as a grid of numbers, but as a luminous Probability Wheel.
Every available action owns a slice of that wheel. At the very beginning, when the agent knows nothing about the world, all slices are the exact same size. Spin the wheel, and every choice is equally likely. The agent is completely open-minded.
Now watch how remarkably simple learning becomes. There is only one golden rule — the entire heart of what researchers call Policy Gradients:
1. Spin the wheel and try whichever action the pointer lands on.
2. If the outcome turns out great, nudge up that slice — widen it so the habit happens more often.
3. If the outcome turns out poor, nudge down that slice — shrink it so the habit fades away.
Notice what happens automatically when one slice grows wider: because the whole wheel always adds up to a full circle, widening a winning slice gently squeezes the other slices smaller. And shrinking a losing slice gives the remaining options a little more room to breathe.
No value map. No backward-rippling maze heat. Just try, feel the outcome, and nudge the habit dials. Try it yourself below and watch a blank, clueless wheel sculpt itself into a sharp instinct.
Spin the Probability Wheel to pick one of four beams aimed at the target arena. Good hits send a green pulse that widens that slice; poor shots send a coral pulse that shrinks it. Move the sweet spot anytime to watch the wheel re-learn.
Click Move Sweet Spot after the wheel has already locked onto one color, and watch closely. At first, the agent keeps picking its old favorite out of habit — and gets hit with a string of coral pulses. Each disappointment shrinks that overgrown slice, letting the other slices open back up until one of them rediscovers the new sweet spot and blooms into dominance.
Why Skip the Score Sheet? Two Superpowers
If value-based methods like Q-Learning already work so well in mazes and board games, why bother learning a probability wheel directly? It turns out that direct habits unlock two superpowers that value tables quietly struggle with.
Superpower 1: Staying Unpredictable (Mixed Strategies)
Imagine playing Rock–Paper–Scissors against a sharp opponent. A pure value-based agent always asks, "Which single move has the highest score?" and picks it every time. If it decides Rock is slightly best, it plays Rock over and over — and its opponent immediately crushes it with Paper.
In games with hidden information, bluffing, or clever rivals, being 100% predictable is a fatal flaw. Because a direct policy is already a Probability Wheel, it has no trouble settling into a balanced mix — a third Rock, a third Paper, a third Scissors — keeping its opponent guessing forever.
Superpower 2: Smooth, Continuous Control
Now think back to steering a car, balancing a robot arm, or aiming a basketball arc. How many possible angles can you turn a steering wheel? Not four. Not ten. There is a smooth, unbroken spectrum of angles between hard left and hard right.
If you tried to use a discrete Q-table here, you would have to chop the steering wheel into clunky boxes and check every single box just to decide which way to turn. A direct policy does something far more graceful: instead of a wheel with four slices, it holds a smooth aiming curve.
Picture a glowing hill — a bell-shaped curve hovering over all possible launch angles. The peak of the hill is your current best guess for where to aim. The width of the hill is how much you are still experimenting around that guess. Nudge the peak toward shots that land close to the target, and let the hill grow taller and sharper as your confidence grows.
Watch this happen live in our second lab. Instead of four colored buttons, the agent controls a continuous luminous launcher. Every shot samples an angle from its glowing aiming curve, arcs across the dark arena, and nudges the curve toward the bullseye ring.
The launcher chooses an angle from the glowing Aiming Curve below. Shots that pass near the Target Ring pull the curve's center toward them and tighten its spread. Click Auto-Train to watch the habit curve glide smoothly into focus.
The Subtle Catch: Noisy Feedback
If nudging habits directly is this clean and graceful, you might wonder: why did we spend so many chapters learning about value maps at all?
Notice what happens when you click Fire 1 Shot a few times in the launcher above. Because the agent learns purely by trial and error, a single lucky or unlucky outcome can tug the habit curve in a jittery direction. And in a long game — say, twenty moves before a win or loss — nudging every single move you made along the way just because the final score was good can accidentally reinforce a sloppy move that happened to be part of a winning game!
To judge whether an action was truly better than expected — instead of merely lucky — our habit learner could really use a partner: a calm, observant judge who keeps track of how well things usually go from each situation. That partnership between a Player who acts and a Coach who critiques is waiting for us in Chapter 9.
Key Takeaways
- A Policy Is a Habit Dial: Instead of scoring every action in a table, a policy-based agent stores its preferences directly as a probability wheel (for discrete choices) or a smooth curve (for continuous control).
- Nudge Up, Nudge Down: Try an action from your current habit. If the result beats expectations, widen that habit so it happens more often; if it disappoints, shrink it.
- Built for Smoothness and Surprise: Direct policies naturally handle continuous actions (like steering or aiming angles) and mixed strategies (like Rock–Paper–Scissors) where being predictable fails.
- The Tradeoff: Pure trial-and-error nudges can be noisy, setting the stage for pairing a direct habit learner with a value-judging coach in the next chapter.