← All blogs

Experiment log · Mad Pod Racing

What 29 experiments taught me about training a game bot.

I trained a bot for Mad Pod Racing, a 2v2 race where each side steers two pods through a loop of checkpoints, three laps to win. The bot reached the world top 0.2%, but the real output was the lessons. A detailed, low-noise reward designed in depth before training anything. No diversity tricks: precision, and a small league of 15 where the worst team drops each iteration and good blood replaces it. Training games kept separate from evaluation games, so a net is never punished for exploring. With those from day one, three weeks becomes three days. Here's how each lesson got paid for, in order.

TL;DRI trained a 2v2 racing bot end to end on one RTX 4060: PPO self-play, DAgger imitation, then small leagues with precise per-role rewards. Three weeks and 29 experiments got it to 459th of 233,508 on the world leaderboard, the top 0.2%. The recipe those experiments distilled would do it again in about three days.

My submitted bot: the hybrid camping its block point submission_hybrid.py · champ #35 vs the best racer
×3

This is the exact bot I shipped (submission_hybrid.py, verified byte-identical). Blue: A0 races, A1 is the hybrid defender. It computes a block point (gold) ~700 units before the leader's next winnable checkpoint and camps on it: the gold line is A1 driving to that point, and it only re-picks a new one when the leader moves on. Here it pins the league's best racer (#37) to just 6 checkpoints while A0 wins 12. On short tracks this camp-and-hold is decisive; on long ones a fast racer out-runs it, which is why the shipped dispatch bot uses the pure racer on those maps.

▶ Watch a real match on CodinGame ↗

The arc fits on one axis: how often the learned bot could beat the strong hand-coded bot I was trying to replace. With coarse, game-level rewards it stuck near 18% no matter how long I trained. DAgger imitation broke the stall, not by teaching a secret skill but by handing the same reward a better base to grow from. Precise, role-level rewards finished the climb. Every point is a win-rate logged in that experiment's own directory.

The climb: win rate vs the hand-coded bot Real logged evals

The wall was reward precision. Game-level rewards stalled at ~18%, the jump is DAgger imitation plus evolution past it, and precise rewards reached 100%. In the end even pure racers could max out the hand-coded bot.

Act I A racer, and the wall

Experiment 01baseline league_state

Start simple: evolve one net through a curriculum

The first trainer was a plain genetic algorithm with a curriculum: learn to drive one pod, then race as a pair, then fight in a league. No gradients, just mutate-and-keep-if-better. It produced a competent racer, the seed for everything after it. What it couldn't do was fight; it had never been rewarded for it.

Fight · two GA-league champions (self-play)recorded: league_state/fights
×3

Champion vs champion on a short sprint: a clean racer, no blocking anywhere.

Experiment 02learned fast hit the wallleague_state_rl

Make every game a gradient step

Evolution is wasteful: a 500-turn game yields one bit, did you win. So I rewrote the sim to run thousands of games in parallel on the GPU and trained a population with PPO, a critic assigning credit turn by turn. It learned fast and crushed its own genetic-algorithm champion. Then I put it against the hand-coded blocker.

90%vs its own GA champion
19%vs the hand-coded bot league_state_rl
Fight · best self-play PPO learner vs the real hand-coded botrecorded: rl/fights, codeingame.decide
×3

Blue is my PPO champion, red is the hand-coded bot. Blue loses.

The reason it lost is worth a detour, because it's the thing I got most wrong all project: the reward. Here's the reward that teaches a pod to race, drawn live over a match it won.

Live: the racer's reward, turn by turn Real match · 6 checkpoints
Turn0
This turn+0.00
Total0.00
Checkpoints0 / 18
Reward → pod A checkpoint +1 approach shaping time −0.05 finish +10
SPEED

A checkpoint reward alone is a locked door: a random net never crosses one, so it never gets a gradient. The blue shaping (reward for getting closer) lets a from-scratch net climb in; the time drip only becomes safe once it already finishes, or it learns to crash on purpose to stop the bleeding.

Act II A better base, then a better reward

Experiment 03plateaued league_state_4pool

Maybe it just needs more, and more diverse, racers

The obvious guess: the racing wasn't good enough. So I grew four genetically separate racer pools that never interbreed, with all the randomness concentrated in immigrants (each with its own mutation size, exploration noise, and entropy) shielded by a grace period. More diversity, more racing. It didn't move.

17%best vs the hand-coded bot, after 1,220 iterations league_state_4pool · eval.csv
Fight · best 4-pool racer vs the real hand-coded botrecorded: 4pool/fights, codeingame.decide
×3

Still losing to red. More racers and more diversity changed nothing; the reward was too coarse to teach anything new.

Experiment 04v1 failed learned to blockleague_state_imit

If you can't learn to block, copy someone who can

I gave up on discovering blocking and cloned the hand-coded bot into a net. First attempt, plain cloning on the expert's own games: it barely drove. The net learns the expert's line, then plays its own slightly-wrong version into states it never saw, and the errors compound (distribution shift). The fix is DAgger: roll out the current net, label the states it actually visits with the expert, retrain, repeat. Now it genuinely learned to block, and pushed the hand-coded bot to the wire.

~12%one-shot cloning (distribution shift)
→
to the wireDAgger clone plays the bot even, and still loses tight; imitation can't exceed the teacher
Fight · DAgger clone vs the real hand-coded botgenerated from champion_imitator
×3

The clone (blue) copies the human's blocking and loses this one by a single checkpoint, 11 to 12. Copying a stateful expert frame-by-frame has a ceiling. To pass the teacher you have to stop imitating and start optimizing, which is the next experiment.

Experiment 05broke the wall league_state_mix

Imitation copies; evolution exceeds

So I seeded a three-pool league from the clones (a racer, a full-heuristic clone, a hybrid clone) and let PPO evolve them against a shared Hall of Fame, a frozen archive of past champions each generation must beat. The same game-level reward that had stalled from scratch grew fast from the better base. One lineage pulled clear, and the exact matchup that lost by a checkpoint before now flips.

94%vs the hand-coded bot
78%vs the hybrid league_state_mix · eval.csv iter 1330
Fight · champion_mix (evolved clone) vs the real hand-coded botrecorded: mix/fights, codeingame.decide
×3

Same opponent, opposite result: blue now beats the bot it was copied from. The first all-neural team to clearly do it.

Experiment 06solved it league_state_v2

Add back the speed the blockers gave up

The evolved champions had drifted blocking-heavy and lost sprints, so I added a from-scratch pure racer, kept pure by a dense racing reward plus a small loss penalty: the project's first precise, role-level reward. It evolved alongside the clones, with advantages normalized per pool so the dense racer's big numbers don't drown the sparse win/loss signal.

100%vs the hand-coded bot
99%vs the hybrid league_state_v2 · eval.csv iter 685
Fight · champion_v2 vs the real hand-coded botrecorded: v2/fights, codeingame.decide
×3

The bot I set out to replace was, at this point, solved.

The net learns from the dense, hackable reward.
But who gets promoted is decided by a clean, deterministic scoreboard: who won.

Act III Raising the bar

With the hand-coded bot maxed at 100%, it stopped being a useful ruler. From here the opponents are my own strongest past champions, so 100% now means "beat the best thing I had." And blocking is the hardest control problem left. Here's what a defender actually does, and the reward that scores it.

Live: the blocker's guard point + hold reward Real match · 3 checkpoints
Turn0
This turn+0.00
Total0.00
Stateferry
Reward → pod B (blocker) holding +0.5 breach −12 win +25
SPEED

A guard point computed in code (700 units in front of the first checkpoint the defender can still win the race to). The net doesn't plan; it just holds.

The defender, up closebreakthrough league_state_dest · exp_destination.py

Teaching a net to actually stop on the point

That guard point is the target. Getting a 24-neuron net to sit on it, with a real racer trying to get past, is the part of this project I'm proudest of. The drill: one defender, one attacker, one computed destination (the next checkpoint it can still reach first). The reward is a balance found by hand: pay for being on the point, weighted by urgency (worth almost nothing while the attacker is far, worth everything as it closes), against a pass-penalty smeared back over the run-up so the net feels the breach coming. Too much penalty and it panics; too little and it wanders. Here is that reward, read off a real training run.

Live: the defender camping, and the reward it earns Real fight · league_state_dest iter 11,820
Turn0
This turn+0.00
Total0.00
Defenderon the point
Reward → the defender, per turn on the point (× urgency) attacker passed
SPEED

The final defender (blue, A1) with the gold tether to its point: it holds 68 to 1,100 units off while the attacker (red) is kept 1,000+ units out for the whole lap. The green reward grows with urgency as the attacker bears down and it refuses to move; a breach would flip it red. This fight has none.

The hard part is physical: a pod coasts about 5.7 times its own speed, so a defender that floors it toward the point sails thousands of units past while the attacker strolls in behind. I didn't train my way out of that, I engineered around it: a hand-coded ferry drives out and brakes for its own stopping distance so it settles dead on the spot, and the net only takes over for the last ~1,500 units, the close-quarters shoving it is genuinely good at.

breached ~every gameiter 0: attacker crosses the defended checkpoint ~0.99×/game, defender ~2,300u adrift
→
held 3× longeriter 11.7k: turns on the point 21 → 63, breaches 0.99 → 0.47, distance to the point roughly halved to ~1,200u league_state_dest · history.csv

The meanest upgrade came last: spawn the attacker on the checkpoint's doorstep at racing speed with a random heading, so it drifts in sideways from every angle a real racer might. Training against that drift is what made the camp hold in real matches; a purely positional reward that scored perfectly in the clean drill let the real, moving leader through about twice a game (league_state_dest_position → _position_real). The winner graduated to full 2v2 games (league_state_deffull), where it picks which checkpoint to camp on the fly. That defender is the one at the very top, camping against the best racer I had.

Experiment 07the leap league_state_v7

Throw out the big net

Everything so far ran on one chunky shared network. I reset the architecture to two tiny role-nets trained from scratch: a 40→24→5 racer and a 30→24→5 defender, each fed only the inputs its job needs. Small and specialized leapfrogged big and general.

100% / 100%vs both prior champion benchmarks league_state_v7 · eval.csv iter 1700
96%DAgger defender, in isolation league_state_v7 · dagger_log
Fight · best mixed team (racer + defender) vs best racerrecorded: v7/fights, light-net champions
×3

Two of the light-net champions fighting. The bigger, more expressive model kept losing to the smaller one that only saw what it needed.

Experiment 08controlled league_state_v7_exp6

Finally, the reward bake-off done right

All project I'd argued with myself about rewards: pure win/loss, dense shaping, or a potential-based reward that's provably neutral? Instead of guessing, I ran them as a controlled experiment: one seed, eight copies differing only in their reward and which job the second pod did, co-evolving against the same Hall of Fame so the scores were comparable.

RP winsdouble-racer + potential-based shaping, strongest of the eight
77% / 85%vs the two frozen v7 champions (iter 600) league_state_v7_exp6 · eval.csv
Fight · reward-experiment champions: best mixed vs best racerrecorded: exp6/fights, light-net
×3

Potential-based shaping won, and its racer became the one every final submission is built on. When you can't reason it out, build the experiment that controls everything but the one variable.

If I started over The three-day recipe

Design the reward first. In depth, before any training run. A detailed, low-noise reward beats hoping the network figures it out; every plateau in this project traced back to reward noise, not network capacity.

Skip the diversity machinery. Four pools and immigrants never moved a number. Precision did.

Keep the league small. 15 teams, the worst one drops every iteration, good blood takes its place.

Never score a net on its training games. Exploration noise belongs in training. Promotion is decided on separate, clean evaluation games, so a net is never punished for experimenting.

Budget: about three days. But honestly, the longer you work on the project and the more experiments you do, the more you learn.

Where it landed

Mad Pod Racing world leaderboard: Hiwaa ranked 459 of 233,508 players, Python 3, score 31.45

My actual row on the Mad Pod Racing world leaderboard: 459th of 233,508, the top 0.2%. Score 31.45, all in Python 3.

MAD POD RACING · 3 WEEKS · 29 EXPERIMENT FOLDERS · ONE RTX 4060
EVERY NUMBER READ FROM THAT EXPERIMENT'S OWN LOGGED EVAL · EVERY FIGHT A REAL RECORDED MATCH