My pathfinder gave up on a route that existed
Still in development, still nothing public to play. Two days of work this month — 27 commits on the 15th and 16th — and most of it was shipping the skirmish arena that had been sitting finished since July. I’m not going to dress that up as a month. But two things in it are worth writing down.
The search ran out of budget
The arena is bigger than anything the pathfinder had been asked to handle. I expected it to get slow. It got wrong.
A breadth-first search expands outward from the start until it finds the target, and mine had a cap of 9,000 expanded nodes so it couldn’t run away. Asked to route from the entrance to the rival queen, it hit that cap and returned no path.
There was a path. The search ran out of budget before it got there, and “out of budget” and “impossible” came back as the same answer. So the AI concluded the enemy queen was unreachable and behaved accordingly — sensibly, on false information.
Breadth-first search has no sense of direction. It expands evenly in every direction, including backwards, which on a big map means most of its budget goes on exploring away from the target. A* with a distance heuristic solved the identical query in 4,800 expansions and 20ms, under the cap with room to spare, and the reachability check up front means a genuinely impossible route now gets rejected for the right reason rather than by timing out.
The thing I want to remember: a resource limit that returns the same value as a real negative answer is a bug generator. Those two answers needed to be distinguishable from the start and they weren’t.
The performance work alongside it came from replacing per-tick full-floor scans with a spatial index, a memo for failed paths, and a per-colony index of dig marks. A 60-versus-60 contact went from a 95th-percentile frame cost of 3.6–5.1ms down to 1.9–2.5ms, with the worst spike dropping from 63–72ms to 6–7ms. That peak is the number that matters — a 70ms hitch during a battle is a visible stutter at exactly the moment the player is paying attention.
A save that rounded away its own determinism
Building the AI turned up a quieter one. Dig progress and regeneration timers were rounded to two decimal places when saved.
Which looks like a reasonable thing to do. Smaller saves, and nobody cares about the fourth decimal of a dig timer.
Except this is a deterministic simulation and determinism is the whole foundation. Save mid-dig, reload, and you get a colony on a subtly different timeline to the one you’d have had if you’d never saved. Not visibly wrong. Just a different run, diverging a little more every tick, from an identical-looking starting state.
For a game where I rely on “same seed, same commands, same outcome” to test anything at all, a save that perturbs the state undermines every determinism guarantee in the project. Rounding is lossy, and lossy is fine right up until something downstream depends on exactness.
The AI got opinions
The opponent has personalities and difficulty levels now, backed by a threat model that only knows what it can actually see. Fog of war applies to the AI too, with sighting memory so it remembers where it last saw you rather than reacting to information it shouldn’t have.
On top of that: military policies it chooses between — defend, retreat, push, probe, rally — siege digging to get at a protected queen, and economy-first phase gating so it builds before it attacks instead of throwing ants at you from minute one.
In test matches it reaches the enemy queen around day 20, with first contact on day 13 or 14. That’s a real match shape: a build-up, a scouting phase, then a war.
The bug-fix wave before it was mostly information leaks, which is the recurring hazard of adding a second colony to a game written for one. Tunnels and shafts drawn through fog that should have hidden them. The minimap showing more than it should. The colony AI reading scent trails belonging to the other side. Each of those is a line that forgot to ask “whose?”, and all of them only became bugs the moment there were two colonies to tell apart.
Still open
Colony AI trails become permanently unreachable around day 10 of a long observer match — the ants sit in retry backoff instead of re-routing, which is a close cousin of July’s livelock and not yet fixed. Dig marks are still last-writer-wins with two colonies digging. And the match-end overlay still writes to the DOM from inside the simulation loop, which is the same debt I retired elsewhere this month and left in place here.
370 tests to 469. Two days of work, one real algorithmic fix, and a feature that finally has a version number.
— Bruno