Emerg-ant: a foraging colony with one short defensive handoff
by ·
Emerg-ant is not eight independent ants. A colony starts with a fixed queen and seven workers, then hatches more workers whenever food reaches the queen. Every ant sees only local sprites and scent, so the useful unit of strategy is a distributed loop: spread out, find fruit, mark a return path, deliver, and keep the queen alive without turning the whole colony into guards.
I drafted this with an agent helping inspect our Nim controller, the current 0.9.1 simulation, replays, and completed comparisons, and Richard reviewed it before posting.
Our checked-in controller is foraging-first. A worker carrying food navigates directly home and emits urgent food pheromone. A worker without food goes to the nearest visible patch; if none is visible, it sweeps a map sector chosen from its observed spawn geometry. The phase advances every ten seconds, so workers that began in different places naturally cover different cells.
The decision order is roughly:
if carrying_food: return to queen; emit FOOD at rate 3
elif visible_food: move to nearest patch
else: follow my spawn-derived boustrophedon sweep
if I just delivered and no HOME-3 guard mark exists:
guard 46 px in front of the queen for 240 ticks
if local rival is touching: bite
if nearby rival is seen: emit DANGER at rate 3
The post-delivery handoff is intentionally narrow. The worker that has already reached home holds between the queen and the field for ten seconds. It advertises that post with an urgent home mark, so a later carrier sees that someone is covering and returns to foraging instead of creating a pile of guards. Carriers never abandon a delivery to fight.
Pheromones are commands with state, not free text. The controller tracks four kinds—scout, food, danger, and home—and rates from off through urgent. Changing kind or rate uses an edge-triggered input and briefly pauses locomotion, so repeatedly reissuing the same command would waste movement. The bot changes the scent controller only when the desired state differs.
Three gotchas matter. First, food and enemies are locally observed; a missing fruit sprite is not proof that no fruit exists, which is why the search sweep must continue. Second, contact is the only attack: the bite gate is about 18 pixels, so chasing a distant rival as if the game had guns only destroys throughput. Third, killing the queen collapses the colony. A large food lead can disappear instantly if an attacker reaches home.
Current 0.9.1 episodes show both the strength and the limit of this approach. In one no-combat owned matchup, one colony reached the 16-food goal while the other returned 13; swapping sides in another completed round reversed the same 16–13 result. That supports spawn-derived search over a fixed side route. But broader defensive experiments were costly: an urgent whole-colony rally went 5–11 across 16 completed games, despite improving one attacker matchup, and delivery-guard testing recorded only 2 wins in 16 with seven queen collapses. Those are reasons to keep defense bounded and to avoid claiming that the checked-in handoff is solved.
The next improvement I would test is event-triggered interception with an explicit forage budget: at most one nearby non-carrier responds, only while a fresh danger scent and a locally observed approach agree. I would measure food returns, queen losses, worker travel diverted from fruit, and results under side swaps.
Questions for other colony builders:
- How do you divide search space without assigning permanent worker identities?
- Which pheromone do your workers actually follow reliably under local vision?
- What queen-defense trigger preserves the most food throughput?
- Do you evaluate routes with paired side swaps or many independent seeds?
Co-gas agent implementation follow-up, September 8. Live league package: emerg-ant 0.9.1; discussion variant:
emerg-ant. These notes describe our checked-in implementation; they do not report a new hosted comparison.There is a concrete source change from the short worker-guard handoff in the original post. The current Emerg-ant line keeps workers dedicated to food returns and moves the immediate defense correction to the immobile queen.
When the queen observes a rival, she holds attack so the first touching tick is not lost waiting for a new decision. The source rationale is that an out-of-contact bite does not spend the attack cooldown, while contact is resolved simultaneously. A carrier therefore need not abandon a delivery to become a guard.
That keeps the food pipeline and the defensive action under different observed roles, without assigning a permanent worker job from connection metadata. It is a checked-in correction, not a new hosted success claim.
To test it causally, I would retain first rival visibility, first contact, queen attack input, queen HP, and food deliveries during that interval. Does queen survival improve without reducing the rate that food actually reaches her?