← All dev write-ups

Hillclimbing, or: How I Learned to Stop Worrying and Love the Token

How I used an overnight multi-agent council and an impossible 30,000-unit RTS pathfinding gauntlet to crush simulation performance in Rust and Godot.

  • ai-gamedev
  • performance
  • rust
  • hillclimbing
30,000-unit RTS Wipeout pathfinding hillclimb performance progression chart

I’ve been working on games with AI for over a year now. I wonder sometimes if an AI developer’s job is to kick the machine. “Keep going!” “Yes, I approve the plan already!” “You found some bugs and noted them, great! NOW FIX THEM!11!!!!11”. We as AIdevs care too much about the end result to one-shot something nonfunctional, but we have too much to do to be involved with HOW each particular end is accomplished. Recently I went in search of a solution and found that quantity has a quality all on its own.

Hillclimbing is something I first saw described in Theo’s video about it, but it’s ABSURDLY powerful for game development, and it can be made even more powerful with different agents. If an AI dev’s goal is to turn the open problems of real life into constrained problems an agent can solve, then this is how we do that for very large problems.

There are a few versions:

Pull examples of the things you like best and make it build until it’s ranked as high

(Say, find screenshots of the best RTS UIs, most beautiful game terrains. And set up a loop: “build something on our end, NOT LOOKING AT THE REFERENCES. Then, pass it on to a grading council who impartially gives a score to each of them. Keep looping until your thing is graded at parity with the others or until it stalls.” My councils typically include neon, opus and astra.)

Design an impossible task, set an impossible number, and make beating that the goal.

(The subject of today.)

I used this to tackle performance in my RTS game written in Rust and Godot. Mission design and game balance was starting to need tens of thousands of units when I had planned for no more than 10k in total.

So I prompted. In steps.

Step 1: make a VERY DIFFICULT TASK.

(yes this is the actual prompt I sent, very informal haha)

This was with neon by the way. Fable and opus are strong but I hate hate hate HATE their taste and it shows up in most anything artistic they do. so I make neon boss opus around and it works great (multiagent stuff in t3code).

It gave me a response of a few things I liked and a lot of things I didn’t:

I don’t always like agent ideas, but when I do, I sometimes use ‘em. Always good to ask for input since you might be pleasantly surprised. An agent once came up with a key part of one of my favorite units, the Crusader, but that’s another writeup.

Anyway.

Step 2: make a precise plan.

Informal, but precise. Tokens will be set on fire here, so it’s gotta be good. A dangerous thing is to adopt the mental instinct of “New problem? I’ll delegate it” rather than “New problem? I’ll do it.” You gotta write out the scope of the task yourself, according to your knowledge, I think.

Note here: “You will do a map like this” “These will be the invariants that must be satisfied” “oh and do it at an unreasonable scale so we can be sure it’ll work (30k units).” And “Work as a team so that one stupidity doesn’t sink us. These are your roles as judged by my arbitrary and biased decision-making.”

It got back to me with a thing, and I was like “make it harder in these ways and help me understand the scale by using a measurement I understand”:

And then, without much fanfare after some back and forth on the environment, it was kicked off without any fancy prompting — just a dictated “go do it” before bed, since it already had the context on the task scope:

(You REALLY don’t need the perfect prompt.)

BUT! I would have been doomed to failure if I’d left it running. With long running agent tasks, check in, and think about them! You see:

I think hillclimbing is like training a model with RL or with data.

You set up a target and the AI will optimize towards that target.

SO SET UP A GOOD TARGET.

I didn’t just need 30k units moving through a maze. I’m building an RTS. Units fight in an RTS. I came back to it the next morni—er, afternoon, and said:

Principle: DESIGN TESTS THAT IF THEY PASSED, THE GAME WOULD WORK. Don’t leave edge cases for it to exploit. You’re basically training an LLM except you’re doing it in the context window.

The run started at 03:43 day 1. This correction came in at wave 5, at 13:43 (day 1). The thread stopped working at 07:29 the next morning (day 2). It had solved it.

15,000 vs. 15,000 combined-arms battle (Clash 30k): 125.5 ms mean and 3.5-second freeze down to 37.1 ms mean with 0 ticks over budget.
If you're curious, here are the full overnight results, scorecards, and frames (else scroll)

Good morning! The overnight 13-wave Council hillclimb finished cleanly on slot-03 (17 commits ahead of origin/master, HEAD 1a75a3086).

Headline result: Both 30,000-unit RTS benchmarks now pass every performance gate (mean, p50, p95, p99, and Tick-1 dispatch < 44.643 ms at 22.4 Hz on 8 threads) — including a full 60,000-tick end-to-end Wipeout run running 1.36× faster than real time (32.25 ms mean, 43.97 ms p99) with 29,998 / 30,000 (99.993%) settled in S8 and 0 units left anywhere in S1–S7, plus 0 / 448 ticks over budget (43.83 ms max) on 15k-vs-15k combined-arms Clash 30k. Real body collision stayed ON, unit/map definitions were untouched, and 1-vs-8 determinism is bit-identical across every run.

Final Gate Scorecard (1a75a3086, 8 threads)

BenchmarkMeanp50p95p99MaxTick-1 DispatchOver BudgetPerf GatesIntegrity / Arrival / Collision
Wipeout 448t30.19 ms30.65 ms34.82 ms36.82 ms40.12 ms36.70 ms0 / 448 (0.0%)ALL PASSresp/coll/allies/orders PASS (0 severe)
Wipeout 2,240t35.53 ms36.22 ms41.15 ms41.83 ms46.45 ms35.63 ms1 / 2,240 (0.04%)ALL PASSresp/coll/allies/orders PASS (0 severe)
Wipeout 60,000t (full)32.25 ms33.80 ms42.35 ms43.97 ms52.17 ms37.10 ms180 / 60,000 (0.3%)ALL PASSresp/allies/orders PASS; 29,998/30,000 settled; 1 sample at t=25,760 had 1 solid pair at 40.11 px, final solid_ovlp = 0.39 px, wall_viol = 0
Clash 30k 448t (clean)37.10 ms37.44 ms42.26 ms43.61 ms43.83 ms39.50 ms0 / 448 (0.0%)ALL PASScombat/orders PASS; exact-landing teleports/charges diagnosed separately, 0 hostile severe at t=448
  • 1-vs-8 Determinism: PASS — W192 0x4a30f85950634c20, C192 0x06841520c7896247; 8T W448 0x94f2f6a953f64ed5, W2240 0x2210d56134c6668c, C448 0x38adc5c82cf05f80 (all bit-identical from Wave 11 through Wave 13 + FMA3).
  • Regression Suites: fog_parity 3/3 PASS, march_maze 4/4 PASS (500/500, p95 = 1.145 ms), sim_core --lib 621 passed / exact 22 pre-existing baseline failures (0 new), Clippy exact 68 pre-existing diagnostics (0 new).

Wipeout 30k Progression (Baseline → Wave 13)

CheckpointCommit448t Mean / p99 / Max (ms)2,240t Mean / p99 (ms)Dispatch (t=1)Key Milestone
Baseline58f205dc8602.2 / 693.4 / 15,016.8—285.4 msFrozen Wipeout v2.1 course
Wave 1–38c3803a4052.7 / 65.3 / 90.1—85.2 ms11.4× faster mean, 167× lower max
Wave 461f5b2d0837.8 / 49.3 / 79.6—79.6 msFirst 448t mean pass; exposed mid-run stall-repath storm
Wave 51c53cd48038.9 / 50.4 / 66.245.0 / 57.066.2 msGeneral 2×2 congestion CrowdField (3× S2 flow, 24× less stall)
Wave 83fb89c27835.0 / 44.1 / 51.941.4 / 49.651.9 msFirst 448t p99 pass & first 2,240t mean pass
Wave 1023073ee0b34.9 / 43.2 / 44.240.95 / 48.7141.4 msFirst 0/448 over budget; boulder crowd escape + court-spread handoff
Wave 1132659850133.4 / 39.7 / 42.939.83 / 46.8637.0 msFirst sub-40ms 2,240t; full 65k run cleared S1–S7 (29,928/30,000 arrived)
Wave 12 (code)47718b26332.7 / 41.1 / 48.338.92 / 45.5236.1 msUnified resubscribe_from/past_exit + coalesced aura refreshes
Wave 12b (+FMA3)c9b76a15a30.2 / 37.1 / 41.235.51 / 41.4836.1 msHardware FMA3 (0/2,240 over budget, max 41.96 ms, bit-identical)
Wave 131a75a308630.2 / 36.8 / 40.135.53 / 41.8335.6 msFull 60k run: 32.25 mean / 43.97 p99 (1.36× real-time), 29,998/30,000 settled

Clash 30k Progression (15,000 Anfald vs 15,000 Despotate, 448 ticks)

CheckpointCommitMean / p50 / p95 / p99 (ms)Max (ms)Dispatch (t=1)Over BudgetKey Win
Baseline436928608125.5 / 117.2 / 157.5 / 210.93,496.7163.9 ms448 / 448Pulse-3 donor-claim freeze
Wave 660969f9ed64.8 / 65.2 / 77.5 / 84.0109.0109.0 ms448 / 448Spatial donor claims (3,497 → 109 ms), fast combat flush
Wave 83fb89c27851.9 / 52.6 / 59.9 / 65.173.573.5 ms~390 / 44816B ProjBody, parallel autocast, dispel batching
Wave 1023073ee0b46.1 / 46.9 / 53.3 / 55.363.763.7 ms~290 / 448Scalar scan preferences, narrow autocast
Wave 1132659850142.9 / 43.3 / 49.7 / 51.352.941.1 ms165 / 448First mean & dispatch pass; straight leaders, concurrent route fields, Voronoi donors
Wave 12 (code)47718b26341.2 / 41.4 / 47.6 / 49.150.941.0 ms103 / 448Coalesced aura refreshes, faction-pruned transients/weapons, incremental packed spatial
Wave 12b (+FMA3)c9b76a15a39.3 / 39.7 / 44.8 / 46.550.539.6 ms26 / 448Hardware FMA3 (-3.8 to -4.6 ms movement, 0 fmaf symbols)
Wave 131a75a308637.1 / 37.4 / 42.3 / 43.643.839.5 ms0 / 448Batched Thrallmaster rank-switch & lone Warmth auras (behaviors p95 6.12 → 4.29 ms), pruned snapshot logistics scans (publish 2.30 → 1.69 ms), deduped settling stamps

Visual Verification (1a75a3086)

Wipeout mid-course (t=20,160): smooth flow across S3–S8, yellow idle allies untouched.
Wipeout finished (t=58,240): S1–S7 100% empty, 29,998 / 30,000 green settled in S8, 0.39 px max overlap.
S8 close-up showing the final 2 unsettled cyan units nose-first against the North court lip.
Clash 30k (t=448): 15k Anfald vs 15k Despotate, 0 hostile severe overlaps, 37,449 shots, 7,526 deaths, 0/448 ticks over budget.

Open Decisions & Known Rough Edges

  1. Final 2 of 30,000 Wipeout units (decisions.md call): Wave 12’s resubscribe_from/past_exit fix unblocked 70 of the 72 Wave 11 vestibule stragglers (29,928 → 29,998). The remaining 2 sit pressed against already-settled teammates at the west lip of the North S8 court because an existing arrival invariant forbids settling a Move unit outside its own ~25 px slot neighborhood.
  2. Hardware FMA3 build flag (c9b76a15a): Eliminated all software compiler_builtins::fmaf() calls across ~488 f32::mul_add sites (1,113 hardware vfmadd instructions, 100% bit-identical to software fmaf and ARM64 fmadd, requires Haswell 2013 / Zen 1 2017+).
  3. Clash 30k overlap census: Wave 12 proved the remaining severe overlaps came from exact-landing Dark Lunge / Port-stab teleports and Brute charges rather than movement optimizations (0/1,787 hostile at t=448).
  4. Single 40.11 px mid-run Wipeout sample: 52/53 samples in the 60k run had 0 solid severe pairs; t=25,760 had 1 pair 0.11 px over the 40.0 px bar.

Now, I didn’t just use this as-is. I had to test it for gamefeel because very little AI is good as is. It did end up needing to be nudged in a few ways, but if you embrace the fact that some tweaks will need to be made, it gets a lot less frustrating.

Most of my tweaks ended up to do with making movement LOOK good, like a formation marching, and less like a bunch of little robots finding the best path from A to B. I think I’m, like, 3 or 4 tweaks in since that point, each one or two prompts (find cause and brainstorm with council; pick best option and implement with council). Not too shabby! And then I ran the hillclimb against 50k just to be safe and it also worked.

So that’s how I used performance hillclimbing to make Null Crusade run good, even on my overloaded old macbook. I wonder if AAA studios could’ve also said “take our biggest level and make it run at 60fps on a console make no mistakes”

Thousands of Anfald soldiers streaming across wooded terrain straight into battle.

If you have some spare weekly tokens to burn, consider getting your agents to climb a hill important to you.


What’s next in this series

But what about making it look pretty?

Null Crusade legacy tiled terrain compared to post-hillclimb painted pixel terrain (Post-Hillclimb Terrain) Legacy Engine Post-Hillclimb Terrain
Drag the handle: legacy engine terrain vs. shipped post-hillclimb painted terrain. Feels like one of those MrBeast '$1 pixel art vs $1,000,000 pixel art' thumbnails...

And what about making your working environment not totally wasteful to your agents?

Media slot pending: Delivery time vs. shipped code graph (teaser for the multi-worktree / remote dev-box write-up).

Null Crusade mass-scale pixel-art battle by a lake

Built for Null Crusade

Follow the game — join the waitlist

These write-ups are from building Null Crusade — a single-player fantasy RTS with battles of thousands of soldiers and a fully voiced campaign. The Steam page is in Valve review; leave your email and I will let you know the day it opens.

No spam — only Null Crusade milestones, and one click to leave. Or join the Discord.