3D Ant Colony

Hundreds of ants, one pheromone field: watch the trail around the wall converge on the shorter route.

Switch to 2D

Presets

Playback

Colony

Wall and food

Camera

Layers

Quality

Model check

The science

Stigmergy

No ant knows the map. Each ant that carries food leaves pheromone behind it; searching ants lean toward stronger pheromone. A trail that is used gets reinforced, so the colony converges on a route without any leader — this is stigmergy, the idea behind ant-colony optimisation algorithms.

The pheromone field

The ground is a 140 × 140 grid. Every step a carrying ant adds d to its cell (capped at 6) and the whole field evaporates by a factor f per 1/60 s: τn = (τn-1 + d) f. For a constant deposit the closed form is τn = d f (1 - fn) / (1 - f), which the page checks against its own loop. The trail half-life is ln 2 / (-60 ln f) seconds (about 0.8 s for the default f = 0.985... the colony refreshes the trail faster than it decays).

Choosing the shorter way

A searching ant samples the pheromone 0.9 units ahead at −0.6, 0 and +0.6 rad and turns toward the strongest, with weight w = min(1, 0.35 · attraction), plus random turning noise and a weak smell of the food within 3.2 units. Returning ants steer straight for the nest and are deflected by the wall. Ants on the shorter side complete more round trips per second, so they lay more pheromone per unit time on that side. The graph of the profile across the wall plane shows the two competing peaks, and the red line on the route-share graph is the share predicted by weighting each route by 1/length.

What is simplified

Real ants use several pheromones, remember landmarks and path-integrate; this is a one-pheromone model. The shortest-path bound used in the check subtracts the nest and food pick-up radii and ignores the clearance ants keep from the wall. Food items are abstract (one item per trip); the stock slider lets the trail disappear when the food runs out. Ants are modelled at about 0.35 scene units; the ant, nest, berries, log, grass and pebbles were modelled and baked in Blender.

Loading model...
Loading Blender model...
Returns via the top route (%)
Food delivered over time
Pheromone across the wall plane
Total pheromone mass
Made with 🟠 Blender · Three.js