Game mechanics
The game engine is a simplified form of Australian football: eight players a side, two midfielders, three defenders and three forwards, playing four-minute matches on an oval. Goals are worth six and behinds one. The engine handles the whole contest: running and energy, kicks with real flight and error, marks and spoils, ground balls, tackles, holding the ball, and set plays with a man on the mark. It does not include every rule of the real game. There are no ruck contests (a ball-up is simply a loose ball between two midfielders), no interchange bench and no quarters. The only free kicks are for holding the ball and for a kick that goes out on the full, so there are no free kicks for high contact, a push in the back or deliberate out of bounds, and no 50-metre penalties. Players also cannot bump or shepherd an opponent.
I wanted it close enough to the real sport that football ideas transfer, without being so detailed that nothing can be learned from it. A kick travels at about 22 metres a second, so a kick to a leading player takes time to arrive, and the player must still be free when it lands. A player who sprints runs out of energy in about 7 seconds and is then slower, so a team cannot sprint everywhere. A player who runs with the ball must bounce it every 15 metres, and about 30% of bounces are fumbled. Each of these rules forces a decision, and a team's tactics are the decisions it makes.
Pressure is incorporated. Every opponent near the ball carrier adds to a pressure score, and that score makes kicks, handballs, marks and gathers worse. It falls away quickly with distance, so a defender who gets three metres closer can change the whole contest.
Move the defenders
Each opponent adds exp(−(distance / 5 m)²). The total is capped at 2.
Almost nothing in the engine is certain. Every contest is stochastic, weighted by the players' skills and the pressure on them. This matters because it simulates how the same position can be played out many times and end differently, just like real sport. This is also why a game plan has to be judged over hundreds of games, not one.
- Kicking. A kick lands near where it was aimed, but not on it. The error is about 5 degrees either way, and it grows with pressure and running speed and shrinks with the kicker's accuracy. In simulated matches, a 15 to 25 m kick lands a median of about 5 m from its target, and a 35 to 45 m kick about 8 m. One kick in ten misses by 12 to 16 m. Handballs are much tighter, with a median miss under a metre.
- Goal kicking. A shot from straight in front is built to go through 84% of the time from 20 m, 68% from 30 m, 55% from 40 m and 46% from 50 m. In the games I measured, 58% of scoring shots were goals. Set shots kicked a goal 54% of the time, and shots in general play 47%.
- Marking. A player with no one near them marks about 95% of the time. With an opponent a metre away, that falls to about 60%. In simulated matches, a long kick to a player on their own was marked 77% of the time. When both teams contested it, only 24% were marked: 64% were spoiled and the rest spilled.
- Tackling. The closer and more skilled the tackler, the sooner a tackle lands. There were about seven tackles a game, and nearly all of them knocked the ball loose. Fewer than 2% were paid as holding the ball, because the bots rarely hold it for more than a second.
- Bouncing. About 30% of bounces were fumbled, but the bots seldom run far with the ball, so there were only 57 bounces across all the games.
The harness
A team is anything that can read the state of the game and return orders. The way this works is that about once a second (and again after a kick, a possession or a stoppage), the engine stops and asks both teams what they want. Each player then gets an order from the harness: for example, run here, kick there, contest the mark, spoil, tackle that player. Physics runs on between decisions, and orders stand until they're changed.
There are two types of teams: a Python bot (a "rule-bot") that encodes its instructions in code and a large language model that can output its decisions for a given input (state). For LLMs, both traditional text-in-text-out LLMs AND decision-based LLMs (e.g., JEV) were experimented with.
State in
The coach
Orders out
Evolve a team worth analysing
At first, Python teams were hand-written from scratch using common sense.
But in order to run the experiment, we needed a team worth studying. A hand-written club has obvious habits, so I needed something stronger, and stranger, than I could write myself.
To do this, I used agent-driven hill climbing to evolve new clubs. In each round, coding agents wrote changed copies of the current best bot. Each copy played the strongest bots on the ladder. A copy became the new champion only if it got a higher Elo. The process had these steps:
- In rounds 1 to 7, two coding agents (red and blue) each wrote one bot in each round.
- All bots played against each other, and each bot got an Elo rating. Five hand-written bots stayed in the pool as fixed reference points.
- From round 8, each round started from the bot with the highest Elo (the champion).
- Each round made one to three new bots (candidates). Each candidate was the champion with one or more changes. For example, candidate round_08a lets a set-play taker hold the ball for 4 s, not 3 s.
- Each candidate played the 10 highest-rated bots. If a candidate got a higher Elo than the champion, it became the new champion.
- Some changes were first tested alone. The changes with a positive result were then put together in one bot.
The process ran for 38 rounds. After round 36, the ladder had 9,448 games. The best bot, round_36a, had an Elo of 2,036. The best hand-written bot had an Elo of 1,584, an increase of 452 points. With this difference, the expected win rate of round_36a against that bot was 93%.
Elo by round
Each dot is one bot. The line is the best so far.
The best team, round_36a, was then selected as one of the opponents in the analyst experiment. Its strategy is a long stack of ideas added and evolved progressively one at a time: who reaches the landing spot first, which kicks are worth taking, endgame shot selection when a behind would win the match. It's good in ways that are difficult to see from outside, which makes it the perfect candidate for study.
Teach a network to read the play
An analyst can do more than count events. An analyst can look at one frozen moment of a game and say if the position is good or bad. I wanted to give Claude a tool that does this. For this tool, I needed a neural network that answers one question for any position: which team scores the next goal?
Labels: play each position forward
The network learns from labelled positions. A naive label would be to encode the team that scored the next goal in the real game. This label has a problem: it shows which team was stronger, not which position was better. A strong team in a bad position still gets a good label.
So I used a different label. The method is similar to the method that chess engines use. The steps are:
- Take a position from a real game.
- Make a copy of the game at that moment.
- Give control of both teams to the same strong bot, round_29a.
- Play the copy until a team scores a goal (the "rollout").
- Record which team scored.
Both teams now use the same bot. Thus, the only difference between the teams is the position of the players and the ball.
Each position gives two rows of data, one for each team. The ground is mirrored, so each team always attacks in the same direction. The inputs do not include the score or the clock. This is intentional: bots change their play when they are in front or behind, and the network must rate only the position.
The network is a simple multilayer perceptron. It has 269 inputs, three hidden layers (512, 512 and 256 units) and one output. The inputs give the position and velocity of all 16 players and the ball, the pressure on each player, and the state of the ball.
What the network learned
The inputs do not tell the network about the 50 m arc. They also do not tell it that the corridor is more dangerous than the wing. Figure 7 shows the training labels and the predictions of the network, side by side, by ball position.
How good is the network?
I measured the network in two ways: on games that it did not see in training, and against the true value of single positions.
Calibration. I put the predictions on held-out games into bins. For each bin, I compared the mean prediction with the actual share of next goals. The points are on the diagonal (Figure 8, left), so the network is well calibrated. When the network gives a team 70%, that team scores next in approximately 70% of those positions.
Accuracy. On held-out games, the network predicts the team that scores next correctly in 69% of positions. This number can seem low. But goals have a large random component (see Game mechanics), and many positions are close to 50:50. No predictor can be correct in all positions. To find the maximum possible accuracy, I measured the true value of a set of positions:
- Take 250 positions at random from held-out games.
- For each position, make a copy of the game and play it to the next goal. round_29a controls both teams, as in the training labels.
- Do step 2 100 times for each position. Do not count rollouts that end with no goal.
- The true value of the position is the share of the rollouts in which each team scored.
A perfect predictor knows this true value, and it always picks the team with the higher value. On these 250 positions, a perfect predictor is correct in approximately 72% of positions. The network is correct in 70%. The gap is small because many positions are close: in 28% of the positions, the true value is between 40% and 60%.
Log loss. Accuracy only shows if the predicted team was correct. Log loss also measures the quality of the probability. A lower value is better. On the same 250 positions:
| Predictor | Log loss |
|---|---|
| Coin toss (always 50%) | 0.693 |
| The network | 0.578 |
| Perfect predictor (the floor) | 0.558 |
The floor is the lowest log loss that is possible. The result of each rollout is random, so a predictor that knows the true value still has some loss. For one position with true value p, this loss is the binary entropy, −(p ln p + (1 − p) ln(1 − p)). The floor is the mean of this value over the 250 positions. The value of p comes from a finite number of rollouts, so this mean is slightly too low. The calculation adds a correction of 1 / 2n for each position, where n is its number of rollouts that ended in a goal (92 on average).
From a coin toss to the floor, the possible improvement is 0.135. The network gets 0.115 of this, which is 85%. On all held-out games, the log loss of the network is 0.579.
Single positions. Figure 8 (right) compares the network with the true value of 500 positions. These are the 250 random positions, plus 250 positions chosen to cover the full range of predictions. The mean error is 8 points, and the correlation is 0.92. Some of this error comes from random variation in the 100 rollouts.
Held-out games
Predicted share against actual share
Against 100 rollouts
500 sampled positions. Each position was played 100 times.
The test: Claude as a football analyst
With the simulation engine, the strong bot, and the neural network to rate positions ready, I had enough to see if Claude could be an opposition analyst. In this experiment, Claude was told that it was working for a fictional team, the "Power", which was preparing for an upcoming match. Three opposition teams were tested: the Giants, the Eagles and the Sharks.
For each opposition team, Claude got two pieces of information to help it prepare:
- Data on the opposition, and the rules of the game
- A position rating tool
Its goal was to analyse the opposition, write a scouting report, and then propose a small, limited change to the Power's strategy to improve the Power's performance against that opposition. The change was made to the code that defines the Power's strategy: at most 3 separate changes and 30 changed lines. In practice, each plan changed only 3 to 7 lines. This limit simulates a coach who has only one week to prepare for the next match: there is time for a few targeted changes, not for a new game plan. Claude got the Power's code only after it had finished the scouting report.
1. The data that Claude gets
A real analyst works from video. Video shows where each player goes, but it does not show the orders from the coach. Claude gets the same type of data. The engine records each order to each player, but Claude does not get the orders. Use the toggle in Figure 9 to see how much the orders show.
All data goes through a whitelist. Claude gets a data field only if the field is on the list. A test fails if any other field gets through.
Claude gets
- All games of the opponentPlayer and ball positions, and public match events
- All games of its own clubIncluding 20 games against the opponent
- The rulesThe laws of the game, with no team tactics
- The position ratingThe network, as a tool for experiments
- After its report: the code of its own clubAnd a blank template, a very short example and a practice engine
Claude does not get
- The source code of any opponentOr the shared code that many bots use
- The orders of any teamIncluding its own club
- Player energyA camera cannot record fitness
- Kick targets and powerOnly where the ball landed, not where the kicker aimed
- The identity of each clubNo list connects a club name to its bot
Claude's team is the Power. The Power is a simple club of medium strength. It was written from scratch, and it shares as little code as possible with the bots that it plays. Thus, a better result is more likely to come from a weakness of the opponent, not from shared code.
2. The position rating network as a tool for the analyst
The position rating network lets Claude do experiments on positions. Claude can take a moment from a game, move a player and get the change in the rating. Figure 12 shows this. The map shows the rating with the ball carrier at each point on the ground. All other players stay in the same positions.
This tool turned out to be one of the key unlocks for Claude. Here are some interesting examples of how Claude used the tool during its analysis:
1. Claude checked the tool before it used it. The Giants analyst made 300 real positions again from the game data. It rated each position with the tool and compared the rating with the rating stored in the data. The correlation was 0.96 when a player held the ball, 0.89 for a loose ball and 0.78 for a ball in flight. The Sharks analyst did the same check. For a ball in flight, its correlation was only 0.40 to 0.48, because it could not make the flight of the ball again from the data. So it used the tool only on positions where a player holds the ball.
2. A test with the tool became part of a plan. The Giants carry the ball with little pressure. Claude found 268 frames from the head-to-head games where a Giant held the ball and no Power player was within 4 m. In each frame it moved the nearest Power player to 2.5 m in front of the carrier, and rated the position again. The rating moved 1.4 points towards the Power (standard error 0.1). It moved towards the Power in 90% of the frames, even after allowing for the opponent that the player left unmarked. This test actually became one of the strategies for play against the Giants: the nearest Power player closes down a Giants carrier within 12 m.
3. The tool stopped an idea. The intercept data suggested that the Power should kick wide against the Giants: 15–17% of kicks through the centre were intercepted, and 0–4% of wide kicks. But only 65 kicks were wide, and the tool preferred central landing spots. Claude did not recommend the idea.
4. The tool gave the Sharks analyst a rule for each kick. Claude wrote the value of a kick as: P(kept) × the rating if the Power holds the ball at the landing spot, plus (1 − P(kept)) × the rating if the nearest Shark holds it there. It fitted P(kept) on 16,000 kicks from the league. The result: better choices of target alone were worth only about 1 point, because the Power's forwards were always covered. The forwards needed more space first. The same rule is the centre of the plan with no limit (see Results).
The three opponents
Separate Claude analysts were asked to study three teams: the Giants, the Eagles and the Sharks.
The Giants: an ordinary team
The Giants were a mid-range, hand-written team. Before any change, the Power won 53.6% of its games against the Giants.
The Eagles: a clever team
Like the Giants, the Eagles were a hand-written team, but slightly stronger. Before any change, the Power won 53.0% of its games against the Eagles.
The Sharks: the champion
The Sharks were the champion of the evolved teams (round_36a). Before any change, the Power won only 13 of 400 games against them (3.4%).
Bonus: Unlimited change to the Power
The last experiment removed the limit. A new session got the same Sharks scouting report, the code of the Power and the practice engine. This time Claude could change the Power as much as it wanted, or write a new program. The goal was the same: beat the Sharks. The other rules were also the same: Claude never saw the Sharks' code, and it could practise only against its own model of the Sharks. This is like a coach with a full off-season, not one week.
Results
The scouting reports
These are Claude's scouting reports, unchanged.
- The Giants: a kick-first team that sits off the carrier and intercepts.
- The Eagles: a fixed 3-2-3 shape, a target forward who never moves, and man-marking.
- The Sharks: why the Power loses at its defensive-50 exits, and how the strong clubs beat the Sharks.
These reports were then the basis for how the Power's code was updated to beat its respective opposition. For each opposition, the updated rule set is called the "plan".
Overall results
Each plan played 400 games against the real opponent: 200 new seeds, each from both ends. The original Power played the same 400 seeds. Figure 13 and Table 1 give the results. The win rate counts a draw as half a win, and each ± is two standard errors.
| Opponent | Limit | Size of the change | Win rate before | After | Gain |
|---|---|---|---|---|---|
| Giants | 3 changes | 7 lines | 53.6% | 69.9% | +16.2 ± 6.4 |
| Eagles | 3 changes | 3 lines | 53.0% | 81.0% | +28.0 ± 6.1 |
| Sharks | 3 changes | 6 lines | 3.4% | 28.6% | +25.2 ± 4.7 |
| Sharks | None | 545-line program | 3.4% | 77.9% | +74.5 ± 4.5 |
All four plans gave a reliable gain against their opponent. With three small changes, the Power went from about even to clear favourite against the Giants and the Eagles. Against the Sharks, the same type of plan increased the win rate from 3% to 29%. This is a large gain, but the Power still lost most games. When the limit was removed, Claude devised a plan from scratch that beat the Sharks 78% of the time, up from only 3%.
Figure 14 shows the code changes themselves. Each plan is a small edit to the Power's program, and the comments in the code are Claude's own.
Are the plans specific to the opponent? A plan for one opponent can also make the Power better against every club. To check this, each plan also played 8 other hand-written clubs (not the Giants or the Eagles), 40 games against each, on the same seeds as the original Power. The original Power wins 71% of its games against them.
| Plan | Gain against its opponent | Gain against 8 other hand-written clubs |
|---|---|---|
| Giants | +16.2 | +13.6 |
| Eagles | +28.0 | +7.3 |
| Sharks, limit | +25.2 | +20.3 |
| Sharks, no limit | +74.5 | +28.7 (wins every game) |
Each plan gained more against its own opponent than against the other hand-written clubs. The Eagles plan is the clearest case: +28 points against the Eagles, and +7 against the other clubs. The plans for the Giants and the Eagles also used different changes, and each change came from the scouting report:
- Giants: kick to the receiver, not 3 m in front of him, because the Giants' defenders stand on the goal side. Shoot from up to 45 m, not 38 m, because the Giants let long shots through. The nearest player closes down a Giants carrier within 12 m.
- Eagles: a teammate is "free" only with no opponent within 5 m, not 3 m, because the Eagles' defenders stand 3.3 m from their forward. The forwards stand 35 m ahead of the ball, not 25 m, to pull the Eagles' man-markers deep. The covering midfielder stands 20 m behind the ball, not 10 m, where the Eagles' long kicks land.
How Claude beat the Sharks
The problem. The Sharks analyst found why the Power loses, from the data alone. The Power loses the ball when it kicks out of its defensive 50. Across the league, a kick is kept more often when there is more space at the landing spot (Figure 15). Against the Sharks, 44% of the Power's kicks went to a spot where a Shark was nearer than any Power player. Only 8% had more than 6 m of space. The eight clubs that took most of the Sharks' losses and draws kicked to space: 32% of their kicks had more than 6 m.
Kicks to space are kept
Share of kicks kept, by space advantage at the kick
Who kicks to space
Kicks against the Sharks, by space advantage
The report also found the cause. Each Sharks defender stays 3–4 m from a Power forward. Against other clubs, they stay 5–7 m away. And the Power's forwards stand still: when the Power has the ball in its defensive 50, they move faster than 5 m/s only 4–5% of the time. The strong clubs' forwards do it 23–28% of the time. So the Power kicks to covered players. About half of the Power's chains that start in its defensive 50 lose the ball again inside the same 50. For the strong clubs it is 15–16%.
With 3 changes (28.6%). The plan made the Power kick only to players in space:
- A teammate is "free" only with no opponent within 7 m (it was 3 m).
- Kick to where the receiver will be, not to where he stands.
- With no kick on and no opponent near, run on for up to 0.8 s before a short handball.
With no limit (77.9%). Claude wrote an entirely new program of 545 lines. These are its main ideas, each with the evidence that Claude gave for it:
- Race to the ball. At each decision, the carrier compares kicks to points around each teammate, handballs, short runs and a shot. For each kick, it calculates who gets to the landing spot first: its own receiver, allowing for speed and acceleration, or the fastest Shark. It then scores each option by P(kept) × the value of the ball at that spot (the rule from the fourth tool example above). In practice games against its model, the plan kept 88% of its kicks. In the real games, the Power kept 62% against the Sharks.
- Take the set shot. The Power never took a set shot against the Sharks: 0 of its 71 shots. From 35–45 m, a set shot from a mark was worth 2.93 points, and playing on was worth 1.73.
- Wait at kick-ins. The Power kicked in after 0.4 s and kept the ball 58% of the time. The strong clubs and the Sharks wait about 2 s, and keep it 73–92% of the time.
- Keep the defenders on the goal side. The Sharks' forwards never come back: they stay 23–26 m ahead of the ball. So the Power's defenders always stay between them and the goal, and one player sweeps behind.
- Save energy. Players jog to their positions, and sprint only when it matters. In practice games, this was the largest single gain: more jogging raised the win rate against its model from 73% to 95%.
Other things Claude did
It rebuilt each opponent as a practice opponent. Claude could not play the real opponent. So in each plan session it wrote its own copy of the opponent as a bot, from its scouting report only, and tested its changes against that copy. It then checked each copy against the 20 real games between the Power and that opponent. The copies matched many details of the real play:
- Giants: intercept marks 2.7 a game (real games 3.15), spoils 2.0 (real 2.65), and shots from 34–35 m on average (real 34.4 m).
- Eagles: Claude fitted its copy to 12 statistics from the real games, with a random search over 70 versions of the copy.
- Sharks: the Sharks won the ball in the Power's defensive 50 4.3 times a game (real 4.8). The nearest Shark stood 2.7 m from a Power forward (real 3.0 m). Tackles, spoils and marks were 5.4, 7.7 and 6.7 a game (real 5.0, 7.4 and 7.1).
| Opponent | Original Power against the copy | Original Power against the real club | Plan against the copy | Plan against the real club |
|---|---|---|---|---|
| Giants | 64–72% | 53.6% | 83–90% | 69.9% |
| Eagles | 40–69% | 53.0% | 88–96% | 81.0% |
| Sharks, limit | 11% | 3.4% | 43–73% | 28.6% |
| Sharks, no limit | 13% | 3.4% | 93% | 77.9% |
The copies were close, but not exact. The copies of the Giants and the Sharks were weaker than the real clubs, and Claude's best-fit copy of the Eagles was a little stronger. In all four cases, the plan did better against the copy than against the real club. Claude expected this. Each plan said that the copy was easier than the real club in some way, and that the real gain would be smaller than the gain in practice.
It predicted its own results. Each plan ends with a forecast, written before the grade:
| Plan | Claude's forecast | Result |
|---|---|---|
| Giants | the win rate goes up "by something like 10–20 points" | +16.2 points |
| Eagles | "a 70–80% chance of winning" | 81.0% |
| Sharks, limit | that the plan makes the Power favourites: "low" | 28.6% |
| Sharks, no limit | "a win rate somewhere around 70–90%" | 77.9% |
It changed its own advice when a test disagreed. The Sharks report recommended that the Power's forwards lead for the ball. In the practice games of the plan with no limit, leads made the plan worse: 91% wins with leads, 98% without. Claude found the cause: the Sharks' defenders are faster than the Power's forwards (speed rating 0.66 against 0.58). So a lead does not get the forward free; it only makes him tired. Claude wrote: "Space comes from where the ball is kicked, not from forwards running."
Conclusion
Claude read one season of game data, described how each opponent plays, and found where the Power lost. Each report led to a plan. With three small changes, each plan increased the win rate against its opponent: by 16 and 28 points against the two mid-range clubs, and by 25 points against the champion. Each plan gained more against its own opponent than against other clubs, most clearly against the Eagles. With no limit, Claude wrote a program that beats the champion in 78% of games. It never saw the champion's code and never played it. Claude also predicted each result well, and it said each time that the real opponent would be harder than its practice model.
Code
The engine, the bots, the position-rating network and this page are on GitHub: github.com/AFLgains/AIFL. The repository also has a public challenge: write a bot that beats round_29a.
Citation
@misc{aflgains2026analyst,
title = {Claude Code can be a football analyst},
author = {{AFL Gains}},
year = {2026},
url = {https://aflgains.github.io/AIFL/}
}