On this page

The idea

A policy is a rule from what the player sees to a move. A policy gradient method stores that rule as a set of probabilities, one per action, and plays by drawing from them. After each outcome it adjusts the probabilities directly: whatever was done before a good outcome becomes a little more likely, whatever was done before a bad one a little less. Nothing has to be learned about how good a board is along the way.

Gradient is the calculus in the middle. For each adjustable number in the rule, ask how much nudging it would raise the probability of the action that was taken. Multiply that by how well things went, and step in that direction. Do it for every step of every game, and the rule drifts toward the actions that preceded good outcomes.

A small example

A machine with two levers. Lever A pays 1 with probability 0.3 and lever B with probability 0.6. You know neither number.

  1. Keep one parameter, call it θ. The probability of pulling B is the logistic of θ, a curve that turns any number into a probability. Start at θ = 0, so the levers are 50/50.
  2. Pull a lever by sampling. Say it was B and it paid 1: nudge θ up a little, so B is likelier next time. Say it was A and it paid 0: leave θ where it is.
  3. Repeat thousands of times. θ drifts up and B becomes the usual choice. That is REINFORCE, the basic rule: the outcome times "how much would this parameter change the probability of what I did".
the two-lever machineA pays 1 with probability 0.3, B with 0.6; the player does not know thatstart 0.5probability of pulling+10+1lever Alever Bring: the lever pulled this time; badge: what it paidthe same shape in Drop7seven bars, one per column, adding up to one1234567before training: 1/7 eachcolumn probabilities; the game only tells the learner one score
Two levers and one parameter. The bars are the probabilities of pulling A and B, and they always add up to one. The loop starts at 50/50; a pull is marked with a ring, its payout with a badge, and each payout of 1 after pulling B raises B's bar and lowers A's. The right-hand panel is the Drop7 shape of the same thing: seven bars, one per column, equal before any training.
  1. Add a critic, a running estimate of how much a pull is worth on average, say 0.45. Reward only the surprise, the payout minus 0.45, so a routine win pushes less hard than a rare one and a routine loss pushes down. That is the actor-critic. The critic is a value estimate used as a baseline; it never chooses a lever.
reward only the surprisesurprise = payout − the critic's estimate01estimate 0.45drifting to 0.50,the running mean+0.55pull 1−0.45pull 2−0.45pull 3+0.55pull 4+0.55pull 5−0.45pull 6+0.55pull 7−0.45pull 8above the line: push that lever's probability upbelow the line: push it down
Eight pulls, each paying 0 or 1, against the critic's running estimate of what a pull is worth, 0.45. A payout above the dashed line is a pleasant surprise and pushes the pulled lever's probability up by the gap; a payout below it pushes down. As pulls accumulate, the line itself drifts toward the running mean.
  1. Add clipping: never let one batch of pulls move a probability by more than a fixed ratio. That is the "proximal" in proximal policy optimisation (PPO), and it keeps a lucky batch from swinging the policy wildly.
the clipnew probability ÷ old probability is held inside a band; here the band ends at 1.20.000.250.500.751.00clip: 1.2 × 0.55 = 0.66old 0.55allowedblockedproposed 0.75A lucky batch can still move the policy, only never by more than the band allows in one step.
A bar for the probability of pulling B, at 0.55 before the update. One batch of lucky pulls proposes 0.75. The clip allows at most 1.2 times the old value, 0.66, so the update stops at the bracket and the hatched part is discarded. That is the proximal in proximal policy optimisation.
  1. Count the cost. Each pull gives one number of feedback and the nudge is tiny, so even two levers take thousands of pulls. In a long game there is one score at the end, and it has to be shared among the hundred decisions that led to it.

How it works

The general method has three pieces. An actor: a function with adjustable parameters that maps what the player sees to a probability for each legal action. Experience: the actor plays, sampling its actions, and each game yields a sequence of situation, action and outcome. An update: for every step, the parameters move in the direction that raises the probability of the action taken, scaled by how much better than expected the outcome was.

"Better than expected" is where the critic comes in. Without a baseline every outcome counts as good news and the updates are dominated by noise. A critic that predicts the expected outcome from the situation turns the raw outcome into an advantage, positive for better than usual and negative for worse. Modern versions, PPO among them, add the clip, gather experience in batches of many games, and run several passes of updates over each batch before discarding it.

The method's appetite is volume. One game contributes one outcome to a network with hundreds of thousands of parameters, so games are counted in the tens of thousands before anything moves. A common shortcut is to start the actor by imitation: train it to copy a teacher's choices first, then let policy gradients improve on the copy. If the copy is poor, the improvement starts from a poor place.

In Drop7

The policy network here reads the public position (the board, the next disc and the rise clock) and emits seven probabilities, one per column, with illegal columns masked out. The reward is the game's final score or the number of moves survived, depending on the experiment. The concept page on learning from play sets these runs beside the value-learning families.

Pages that trained a policy directly:

What it cannot do

The imitation shortcut failed at its gate. The PyTorch clone matched its two-move teacher on 47.2% of held-out decisions against a 55% requirement, and a single permitted correction left agreement very slightly worse (A PyTorch policy network, cloned then trained by playing).

The completed policy-gradient run then showed what the method's volume buys. Over 32 rounds and 16,384 games it improved its own clone by about 9%: 142,677.781 points against the clone's 130,797.406 on the single 64-game development cohort, with a one-sided 95% lower bound on the paired difference of −141.054, so it did not clear "better than the thing it started from" with confidence. Its score was 0.590004 of the two-move teacher's on the same cohort, and below the fair one-move search's 180,713 (same page). Every performance gate failed except zero censoring.

The constrained actor-critic never reached a screen. On its mandatory 512-game calibration its terminal-risk upper bound was 0.10496 against a fixed 0.02 limit, so the checkpoint was sealed untrusted and no gameplay screen was opened (Learning a policy with explicit safety constraints). One score per game is a thin signal. In the recorded runs it was enough to move a policy a little and never enough to close the gap to the teacher, let alone to the reference.