A foraging ant colony, modelled on the real thing. Hundreds or thousands of ants leave the nest, search the floor for food, and haul it back — yet no ant can see the big picture, knows where the food is, or is told what to do. Out of nothing but local rules and evaporating scent, the colony discovers and reinforces the shortest paths between nest and food. This is ant-colony optimisation, the algorithm, running live.
Every ant lays one of two pheromone trails and follows the other:
Each scent evaporates and diffuses every tick, so dead ends fade while busy routes get re-painted and sharpen into roads. Because a scent dab weakens the longer an ant walks since its last reward, the two scents form gradients that point exactly where each kind of ant needs to go.
Every map — nest position and food piles — is generated from a 32-bit seed: copy it to save a layout or paste a friend's, then Load. Drag on the floor to feed the colony a fresh pile (toggle the button to move the nest instead). Scatter rings the nest with food; Auto-feed keeps it fed. The presets tune the ants' senses and the scent's persistence.
Toggle Audio (the a key) and the colony conducts a generative ambient
piece, driven by how much food is in transit. A productive colony with full highways makes the music
busy and bright; a stalled, searching one makes it sparse and low. Pentatonic tuning means it never hits
a wrong note. All synthesised live with the Web Audio API — no files, no network.
space pause · r randomize · m scatter food ·
e auto-feed · p palette · a sound ·
n reseed · h hide panel · i this panel
A single self-contained HTML file · no libraries, no network, no assets. Real-time agent simulation on two diffusing scent fields. A companion to Primordium & Mycelia. Built with Claude.