VisualAI
Chapter 7 · Other Ways to Learn

Trial & Error

No examples, no labels — just rewards. This is how AI learns to play games and steer robots: try, fail, repeat.

10 minLesson 19 of 23

Supervised learning needs labelled answers. Unsupervised learning needs none. There's a third way that needs neither — just the occasional reward — and it's how AI learned to beat world champions at Go.

Think of training a dog. You don't show it a thousand labelled photos of “sitting” — you wait for it to sit, then give a treat. Over time it connects the action to the reward. This is reinforcement learning: an agent acts in a world, receives rewards, and gradually works out which behaviours pay off. The agent below knows nothing — not even where the goal is.

Gridworld Agent

Press Train and watch a plan appear from chaos

🏁⚠️⚠️⚠️⚠️

The agent only knows: 🏁 feels good (+1), ⚠️ feels bad (−1), every step costs a little. Colours = how good each square feels; arrows = the plan it's formed.

Episodes0
Reaches goal0%

No examples of the right path are ever given. The agent stumbles into the goal by accident, remembers the reward, and slowly turns luck into a plan. That's reinforcement learning.

It's never shown the right path. It only feels 🏁 = good, ⚠️ = bad, and stumbles its way to a strategy.
Try this

Hit Train. At first the agent flails — wandering, dying in the hazards, rarely reaching the flag. But watch the squares slowly tint teal near the goal and red near the pits, and arrows snap into a route. When the success rate climbs, press Watch it play to see the plan it built. Then Forget everything and do it again.

Turning luck into a plan

The colours are the agent's sense of value — how good each square feels — and the arrows are its policy. The trick (called Q-learning) is that the value of a square is the reward there plusthe value of where it leads, so the “this is good” signal ripples backward from the goal, one square at a time. And it must explore — take random moves — to ever discover the goal in the first place, then exploit what it learned.

Key idea

With nothing but a reward signal, an agent can invent sophisticated behaviour from scratch — no demonstrations required. This is how AIs mastered Go, Atari, and StarCraft. It's also the RLhiding inside “RLHF,” the technique that turned a rambling text predictor into the helpful assistant you actually talk to.

A warning that keeps researchers up at night: agents optimise the reward you wrote, not the one you meant. Give a boat-racing game points for hitting targets and it'll spin in circles farming targets forever instead of finishing the race. Designing rewards that can't be gamed is a deep, unsolved art.

The payoff

That completes the three ways machines learn — from labels, from structure, and from reward. You now have the whole toolkit. The final chapter is the most practical of all: not how these models work, but how to wield them well — starting with the hard edge of their memory.