← Builds Toy · Reinforcement learning

Two players learn what a good shot is.

Green and Red play one on one, first to 11. Nobody tells them which shot to take. Each one tries moves, gets a reward, and leans toward what paid off. Change the rewards and watch their game change.

Green 0 Red 0 first to 11

01 · The brains

What they've learned so far.

Each player keeps a separate shot mix for six situations: behind by 3 or more, a close game, or ahead by 3 or more, and whether they are fresh or rattled (just got dunked on or had their ankles broken, so they shoot worse for two trips).

02 · The rewards

You set the rewards. They work out the shots.

Game points decide who wins. The reward is what each player learns from: the points (if that box is ticked), plus its coach's bonuses, plus the lead swing. Reward only dunks and the player never learns anything about jumpers, because a made jumper and a missed one both pay the same.

The game itselfShot odds

Rattled players hit 40% fewer jumpers, 15% fewer finishes at the rim and lose the ball more often.

03 · Over time

Shot mix, possession by possession.

01 · Act

Pick a move

Each move has a value: the reward the player expects from it. Better moves get picked more often, but never always. Exploration decides how often it still tries the ones it rates lower.

02 · Reward

Get paid

The possession plays out with the real odds. The reward is whatever its coach pays for that outcome, plus the lead swing if that coach cares about the lead.

03 · Update

Nudge the estimate

The value of that move moves a small step toward the reward it just got. With look-ahead on, it also counts what the next situation is worth, so a move that rattles the other player gets credit for the shots they miss after.

Q(s, a) ← Q(s, a) + α · [ r + γ · max Q(s′, ·) − Q(s, a) ]π(a | s) ∝ eQ(s, a) / τ, never below 1%

This is tabular Q-learning, the simplest form of reinforcement learning. The same loop, with a neural network in place of the table, is how game-playing agents learn.