Tuesday, 14 July 2026devblog

Eleven a side

I did not write AI for 22 players. I wrote it for two. One Team Brain per side, and team shape and performance turned out to be the same problem with the same fix.

Day 30ELEVENA SIDE

It is a real football match now. 11 v 11 on a regulation 105 by 68 metre pitch. And I did not write AI for 22 players. I wrote it for two.

Twenty-two players each deciding for themselves gives you under-8s football: everyone chases the ball, nobody holds a shape, because nobody is thinking about the team. So I stopped writing player AI and wrote a Team Brain, one per side. It thinks ten times a second and hands every player a target. Players do not decide where to be. They read.

What it actually does is move a block. It slides up and down the pitch with the ball, shifts to the ball's side, squeezes tight when you lose possession and spreads when you win it. That is just football. Every position is your formation slot, transformed by that block. Formations are eleven numbers in normalised pitch space, 0 at your goal and 1 at theirs, so a 4-3-3 works on any pitch size and mirrors perfectly for the away team with zero if-statements. 4-3-3, 4-2-3-1, 4-4-2, 3-5-2 and 5-3-2 are all live.

And here is the part I love. Twenty-two players scanning each other every frame is a slideshow. One brain per team is not. Team shape and performance turned out to be the same problem, and the same fix. The brain says where your zone is; the evaluator from last week says where the space is inside it. Team shape and individual intelligence compose instead of fighting.

The pitch got the same treatment. Twenty-two hardcoded numbers scattered through the AI became one data asset. The AI reads it, and the shader that paints the white lines reads it too, so the box the keeper believes in and the box on the grass are guaranteed to be the same box.

Bug of the week

The opposition stopped attacking and started running at their own goal. Two causes. One: each player carried a hand-typed "goal to attack" coordinate, and I had resized the pitch. Now it is derived from the pitch and your shirt colour. It cannot go stale and it cannot be typo'd. Two: whenever the ball was loose, the brain told both teams to defend. On a 4v4 court the ball is never loose. On a 105-metre pitch it is loose constantly. So both teams turned round and jogged home. Repeatedly.

Day one: a capsule and a ball. Day thirty: 22 players, in formation, on a regulation pitch, defending as a unit. Next: teaching them to actually defend.

Shipped: Team Brain · 5 formations · regulation 105 × 68 m pitch · pitch config