How the Airplane network works

How a game strategy becomes numbers in a small network, with no training. This page covers the best attempt we made for this game, a handwritten network, which averages 435.8 points. The positions and values below come from its real weights.

The game

A plane on the bottom row of a 10x10 grid moves left, right or stays. Red objects fall and end the game if they land on it. Green ones fall and score a point. There's one twist: 10% of the time, the game repeats the plane's previous move instead of the one chosen.

The network has two hidden layers of 32 units each. That size was fixed in advance so that PPO, a standard reinforcement learning method, could train exactly the same network from random weights, for a fair comparison with the handwritten one. The handwritten design ends up using only part of it.

The problem the network has to solve

A network unit only adds up its inputs, each multiplied by a fixed weight, and then fires if the total is high enough. That makes a question like "is this red dangerous?" surprisingly hard, because the answer depends on where the plane is. A red in column 4 is an emergency if the plane is in column 4, and irrelevant if the plane is in column 9. One fixed weight on that red can't be both.

The fix is to give each plane column its own small group of units, and use one enormous weight as a switch. Each unit's weight on "the plane is in my column" is 8 billion, and its bias is about −8 billion, so the two cancel only when the plane is really there. In every other column, the unit stays firmly off, whatever else is on the board.

So each group can use weights that assume it knows where the plane is.

The strategy in plain words

Give each of the three options, stay, left and right, a score, then pick the highest. The score is just a weighted sum over the objects on the board. Rows are numbered from 0 at the top, the plane is on the bottom row, row 9, and everything falls one row per step. So a red on row 8 lands on the next step, one on row 7 the step after, and so on. For each option, the score adds up these cases:

What could happen after this moveScore
Hit by a red right away. A red is on row 8 above the column this move goes to, so it lands on the plane straight after the move.−10,000,000
Hit after one repeat. One move in ten, the game repeats the previous move. If it repeats this one, the plane moves one more column the same way, or stays put if the move was "stay". A red on row 7 above that column would then hit it.−120,000
Hit after two repeats. The same, if a left or right move repeats twice in a row, which happens 1 time in 100: a red on row 6, one more column along.−12,000
Fewer ways out on the next step. After this move, the plane again has three choices: stay, left or right. Each red that would block one of them counts against this move, so the plane heads where it keeps the most escape routes. At a wall, the missing choice counts as blocked.−3,000
Hit after three repeats, or a red coming down this column. Three repeats in a row, 1 time in 1,000, into a red on row 5. Or a red on row 5 directly above where this move ends, which will land in four steps unless the plane moves away. A red on row 4 there costs a further 120.−1,200
A green within reach. A green the plane can still get under before it lands. It's worth 4,000 on row 8, halving for each row further up, plus a little more the closer it is to the plane's column.+4,000, +2,000, …
Room to dodge. Ending nearer the middle of the board, where there's more room to dodge, is worth a few points. It only matters when everything else is equal.a few points

The gaps between these numbers act as an order of importance: enough greens can't outweigh landing on a red, because no realistic board holds thousands of them.

The layers

The first layer does the arithmetic. Every red and green on the board adds something to each option's score, following the table above. For example, a red on row 8 above where moving left would take the plane adds −10,000,000 to left's score. Instead of working out each score separately, each unit compares two options directly. The unit "left > stay" has one input per board cell, saying whether a red or green is there, and gives it a weight equal to what an object in that cell adds to left's score, minus what it adds to stay's score. Adding these up over the objects on the board gives left's score minus stay's score: positive if moving left is better than staying, negative if staying is better. The unit fires if the result is at least 1. The scores are whole numbers, so 1 is the smallest real difference. Three such comparisons, left > stay, right > stay and left > right, are enough to rank three options. Each plane column has its own three, switched on only when the plane is in that column, and a column at a wall needs only one, since the plane can move only one way from there.

The second layer makes the decision from those yes/no answers: go left if left beats both staying and going right; go right if right beats staying and left doesn't beat right; otherwise stay. So a tie means staying. Unused units simply have all-zero weights.

One move, followed through the network

Pick a position from a real game. Then pick a comparison to see which objects push it, and by how much.

Board, row 0 at the top

  • red
  • green
  • plane

Layer 1: compare the options

Layer 2: decide

Output

Looking at the weights directly

These are one unit's actual weights, drawn on the board, in score units. Blue pushes this comparison up and orange pushes it down. Colour uses a log scale, because the values range from 15 to 10 million. Hover or tap a cell for its value.

Weights on red objects, rows 0–8

Weights on green objects, rows 0–8

Show these weights as a table

What to look for: in "right > stay", row 7 is lopsided: +24,000 one column left of the plane, +960,000 in its own column, 0 one column right, and −984,000 two columns right. That's the repeat rule. If "right" is chosen and then repeats, the plane will be two columns right when a red on row 7 lands, so that cell is heavily penalised. If "stay" repeats, the plane stays put, so a red directly above favours moving away. In the green grid, the blank corners are greens too far to the side for the plane to reach in time.

How the design got here

Only attempt 1 was written without ever running the network. Each revision came from reading how games ended.

AttemptMeanWhat changedWhy
1, blind167.7Original designNever run before scoring
2254.2Priced risks by their odds of causing a deathAll deaths came from repeated moves
3214.5Priced safety much higherDeaths were mostly repeats of staying. It made things worse
4331.3Avoided cells with few safe options next stepMost deaths followed a step with no safe option
5334.3Valued nearby greens above one or two blockersGreens per step had fallen
6435.8Priced long repeat chains, stronger blocker penaltyMany deaths took 3 or more repeats in a row

What this does and doesn't show