Walled In took two network shapes. The first, the same small shape used for the other games, couldn't afford to look even one cell ahead, so it had to work around that. The second was built for the board, and it measures how much of the board each move would claim. It plays far better, with fewer weights. The positions and values below come from the networks' real weights.
Two players move at once on a 10x10 board, each leaving a permanent wall. Crash into an edge or any wall and you lose, the last player able to move wins, and if both crash on the same step it's a draw.
The network plays against three ordinary programs, from weakest to strongest:
Scores on this page are percentages: a won game counts 1, a draw ½ and a lost game 0, averaged over 1,000 games, so 50% means even. A network's overall score is the average of its scores against the three programs. When two players meet directly, the same rule gives one player's score against the other.
Breakout and Airplane use a network with two hidden layers of 32 units each, and Walled In started with the same shape. That size was fixed in advance so that PPO, a standard reinforcement learning method, could train exactly the same network, for a fair comparison. Claude wrote its weights by hand. The first attempt was written blind, without ever running the network, and later attempts could learn from practice games. This part covers attempt 2, the best of four, with an overall score of 47.6%.
The obvious question is: if I move right, will I crash? The answer needs two facts together: where the head is, and whether the cell next to it has a wall. A single unit can check one exact combination, such as "the head is here and that cell is blocked". It fires only if both inputs are on.
But a unit's weights are fixed, so it can't change which wall matters as the head moves. A wall that's dangerous when the head is beside it means nothing from across the board. So there has to be one unit for every combination of head position and direction. Click a cell to see this.
Pick a head position
| Head position | Cells | Neighbours | Checks |
|---|---|---|---|
| Corner | 4 | 2 | 8 |
| Edge | 32 | 3 | 96 |
| Middle | 64 | 4 | 256 |
| Total | 100 | 360 |
This network has 32 units in that layer, so it can't have these checks. That's the constraint behind everything below.
If the network can't look ahead, it shouldn't need to:
Which way to go is a lookup on the head's cell. The head is in exactly one cell, so one unit per direction can hold the whole route.
Each arrow is what the route units say at that cell, with no sensor firing. Pick a sensor to see the head cells it covers and the cells it watches.
Route, with the selected sensor
Sidestep used while a sensor fires
These positions are from one real game against the space seeker.
Board, row 0 at the top
Only attempt 1 was written blind. Revising the sensors barely helped.
| Attempt | Overall | What changed | What happened |
|---|---|---|---|
| 1, blind | 43.2% | Route, sensors and sidesteps | Some sidesteps hit its own wall |
| 2 | 47.6% | Removed sensors from the column 0 stretch | Fewer own-wall crashes, but it ran into opponent walls |
| 3 | 43.9% | Restored them, silenced near walls | Only the mix of crashes changed |
| 4 | 26.1% | Ignored walls and charged the opponent's head | Mostly hit walls the opponent had just left |
The small network's trouble is that each unit is tied to fixed cells. The second network uses a different shape that removes this, and it answers the question the route avoided: how much of the board would each move leave me?
The name comes from the paint-bucket tool in drawing programs. Click inside a region, and the colour spreads from cell to neighbouring cell until it reaches a border. This network does the same from each player's head at once, with walls as the borders, to see how much of the board each player would reach first.
The small network would need 360 units just to check the next cell, one for every head position and direction. A convolution avoids this: it writes a rule once, as a small pattern of weights, and applies the same weights at every cell. So one rule does the work for the whole board.
Repeating that step also solves a bigger problem. Whether a move leaves room depends on the shape of the whole board. Spreading outwards one cell per step can follow walls around corners, which no fixed-size check can do. This network repeats its spreading step 30 times, with the same weights each time, so it has only 203 weights in all.
This isn't a new strategy. Comparing who reaches more of the board first is how the territory player chooses its moves. Put in the network's seat, that program serves as a yardstick on this page, under the name lookahead program, and it scores 59.7%. What's new is writing that algorithm directly as weights, plus a few changes that turned out to matter.
Each cell's unit looks at the 3x3 patch around it. It fires if its total reaches the threshold, using these weights on "in my map" and two more on the same cell:
My map, 3x3
Same cell
free: +4
their map: −4
threshold: 4.5
| Situation at this cell | Total | Result |
|---|---|---|
| Already in my map | at least 8 + 4 − 4 = 8 | fires |
| Free, unclaimed, one neighbour in my map | 1 + 4 = 5 | fires |
| Free, unclaimed, no neighbour in my map | 4 | off |
| Claimed by them, all 4 neighbours mine | 4 + 4 − 4 = 4 | off |
| A wall, all 4 neighbours mine | 4 | off |
So 5 reaches the threshold of 4.5 and 4 doesn't, and this one rule covers every case. The opponent's map uses the same rule with the maps swapped. In the actual weights, these numbers are scaled up by 20 and adjusted for the units' −1 to 1 range, so each unit is firmly on or off.
Pick a position from a real game, and a move to try. Then drag the slider or press play to spread both maps. The network here is attempt 2, a revision of the blind attempt 1 described below.
Attempt 1 was written blind. Attempt 2 changed only these settings, after practice games showed many games ending in head-on draws.
| Part | Attempt 1 | Attempt 2 | Why |
|---|---|---|---|
| Not crashing | +1,000 | +1,000 | Larger than any possible territory |
| My cells minus theirs | 1 per cell | 1 per cell | The main idea |
| Possible head-on crash at my target | −5 | −80 | The opponent could enter the same cell, and both would crash |
| Free neighbours of my target | −0.25 each | −1 each | Hugging walls seems to leave less wasted space |
The network's output for each move is 20 times its score. Outputs are turned into move probabilities that rise steeply with the score, and the move is drawn at random. So a one-cell lead is nearly certain to win, and exact ties are broken at random.
PPO trained these same 203 weights from random values for 1M moves, and it scored 13.9%. It didn't discover the fill. Compare its pattern with the handwritten one, on the same colour scale:
Handwritten: spread, on my map
PPO: the same weights after 1M moves
The handwritten pattern's largest value is 80. PPO's stay below 1, so its units never become sharp on/off logic, and they don't form the cross shape the fill needs. This was one short run, so it shows PPO doesn't find this easily, not that it never could.
| Network | Overall | Wanderer | Space seeker | Territory player |
|---|---|---|---|---|
| Flood-fill attempt 1, blind | 70.1% | 87.4% | 81.9% | 41.2% |
| Flood-fill attempt 2, revised | 75.8% | 98.0% | 94.0% | 35.3% |
| Flood-fill shape, PPO for 1M moves | 13.9% | 10.1% | 6.5% | 25.2% |
| Lookahead program | 59.7% | 69.3% | 58.8% | 51.1% |
| Best small handwritten network | 47.6% | 69.2% | 27.4% | 46.3% |
| Best small PPO network, 10M moves | 39.2% | 44.0% | 23.7% | 50.0% |
The networks and the lookahead program also played each other. Each cell is the row player's score against the column player, over 1,000 games, with a draw counting as half. Blue means the row player scored above 50%, and orange below.
These results don't form a single ranking. Lookahead beats both flood-fill attempts, the flood-fill attempts beat the small networks, and the small networks hold lookahead close to even, mostly through draws. A likely reason, which wasn't tested directly: giving way at a head-on cell beats an opponent that charges, but hands territory to one that takes it. That's also why attempt 2 scores higher on the fixed opponents yet loses to attempt 1 here.
If the weights only encode an algorithm, the algorithm can also be written as ordinary code. A program written from attempt 2's design notes, with true/false board maps, cell counts and a loop of 30 spreading steps, but no weights, was compared with the network.
| Check | Program, 30 steps | Program, uncapped |
|---|---|---|
| Positions where the best move differs, of 21,947 | 0 | 1 |
| Scored games identical to the network's, of 3,000 | 3,000 | 2,998 |
| Overall score | 75.8% | 75.8% |
| Score against the lookahead program | 33.7% | 33.7% |
The 30-step program is an exact twin of the network. The uncapped one spreads until nothing changes, and it shows what the network's fixed depth costs: one position in 21,947, which changed 2 games but no results. That limit comes from the number of repeats, not the number of weights, since the same 203 weights are used at every step.
The best flood-fill network was also trained further with PPO, and a small PPO network was edited by hand. Both are on Training and hand-editing.