Termite Stigmergy Sorting Screensaver
This screensaver simulates real termite-inspired stigmergic sorting — simple wandering agents that pick up a wood chip when they bump into one alone and drop it when they bump into a pile, using nothing but their immediate surroundings. With no leader, plan or map, scattered chips reliably self-organize into a handful of large sorted piles.
How the Termite Stigmergy Sorting screensaver works
Simple agents wander the grid randomly, each carrying at most one wood chip at a time.
An empty-handed agent that bumps into an isolated chip picks it up; a chip-carrying agent that bumps into an existing pile drops its chip there instead.
There is no leader, no shared memory, and no global plan — each agent reacts only to what's directly in front of it right now.
Despite that, this purely local rule reliably clusters scattered chips into a shrinking number of larger piles over time, the same real emergent behavior seen in real termite mounds.
Stigmergy and the sorting of wood chips
Stigmergy is the idea that individuals coordinate by changing their shared environment instead of talking to each other. The term was coined in 1959 by the French biologist Pierre-Paul Grassé, who used it for termite behaviour and defined it as the stimulation of workers by the performance they have achieved. The work itself tells the next worker what to do, so no termite holds the plan.
The chip-sorting rule on this screen is a well-known toy model of that principle. Because lone chips are picked up easily and dropped only beside other chips, small piles are eaten away while larger ones grow, a rich-get-richer dynamic that steadily reduces the number of piles.
The mechanism has been tried in real robots. In a 1994 paper, Beckers, Holland and Deneubourg described mobile robots that gathered 81 scattered objects into a single pile using stigmergy, and found that completion time fell with up to three robots but rose with four and five, as robots began to destroy each other’s clusters. The outcome is statistical, so the number and position of piles differs every run, and stragglers can linger because a wandering agent has to bump into them to move them.
A worked example
Start with chips scattered evenly across the grid — within a few hundred steps, small clumps of two or three chips form, then those clumps themselves keep growing as wandering agents ferry stray chips toward them, leaving fewer, larger piles.
Settings & tips
- Termite count controls how many wandering agents work the grid at once.
- Chip color recolours the wood chips and piles.
- The grid reseeds with freshly scattered chips once sorting is nearly complete.
Frequently asked questions
- Do the termites have a plan or leader?
- No — each agent reacts only to whatever is immediately in front of it; the sorting into piles is a genuine emergent effect, not a coordinated plan.
- Is this based on real termite behavior?
- Yes — real termites and ants use comparable local pick-up/drop-off rules to build and organize their mounds, a phenomenon called stigmergy.
- Is a key needed?
- No — it's a pure local computation.
- Is it free?
- Yes — free, no download, in your browser.
- Why do piles merge instead of staying separate?
- Agents tend to remove chips from small piles, where a chip has few neighbours, and add them to large ones. Over time this transfers material from small piles to bigger ones until only a few remain.
- Have robots actually used this rule?
- Yes. In 1994 Beckers, Holland and Deneubourg showed a group of simple mobile robots clustering 81 scattered objects into one pile, coordinating only through changes to their surroundings.