Craig Reynolds’ steering behaviours give each agent a desired velocity — seek a target, flee a predator, follow a path — and steer towards it with a limited force. His boids add three local rules: separation, alignment and cohesion. No bird knows the shape of the flock, yet the flock appears.

The same idea scales to ant colonies laying pheromone trails, crowds evacuating a room, and Physarum slime mould, where tens of thousands of tiny agents build networks that resemble the roads between cities.

Every simulation below runs right here in your browser, for free, with live controls. Open one, change the sliders, and use the mouse — most of them respond to it.

Autonomous Agents simulations

Steering Behaviors

Steering Behaviors — interactive simulation

An autonomous agent picks its own forces. Craig Reynolds' formula is the core of it: steering = desired velocity − current velocity, capped at a max force. Lowering max force makes the vehicle less agile.

With debug on: green = velocity, blue = desired velocity, red = steering force.

Open Steering Behaviors →

Flow Field Following

Flow Field Following — interactive simulation

A flow field is a grid of vectors covering the canvas. Each vehicle looks up the cell it is in and uses that arrow as its desired velocity. Thousands of vehicles following it trace out the hidden currents, like iron filings around a magnet.

The field can come from Perlin noise (evolving over time), or from a vortex or sink centred on your mouse.

Try this: Turn on "Show field" to see the vectors, then switch to "Vortex (mouse)" and move around.

Open Flow Field Following →

Flocking (Boids)

Flocking (Boids) — interactive simulation

Craig Reynolds' boids: each bird follows three local rules and only sees neighbours within its perception radius.

No bird is in charge, and no rule describes "a flock", yet flocks emerge. This is emergence. A spatial grid keeps neighbour lookups fast enough for hundreds of boids.

Try this: Set cohesion to 0, then separation to 0, and see how each rule shapes the flock. Click to add boids.

Open Flocking (Boids) →

Path Following

Path Following — interactive simulation
Generation 2: an evolution of Steering Behaviors

Reynolds' path following combines seek with a bit of geometry. Each vehicle:

A separation force stops vehicles piling on top of each other. Inside the path they drift freely, which looks surprisingly natural.

Try this: Drag on the canvas to draw your own path. Shrink the radius to make them hug the centre line.

Open Path Following →

Predators & Prey

Predators & Prey — interactive simulation
Generation 2: an evolution of Flocking (Boids)

Flocking boids now share the world with predators. Prey flock and flee any predator nearby. Predators chase the nearest prey they can see, gain energy by eating, starve without food, and reproduce when well fed. Prey breed slowly when there is room.

Nothing here describes populations, yet the counts rise and fall in the boom-and-bust cycles of the Lotka–Volterra equations from ecology. Many prey → predators multiply → prey crash → predators starve → prey recover…

Try this: Lower the predator hunger rate and see whether the ecosystem collapses or stabilises.

Open Predators & Prey →

Ant Colony & Pheromone Trails

Ant Colony & Pheromone Trails — interactive simulation
Generation 2: an evolution of Flow Field Following

In the flow field demo the field was given. Here the agents write their own field. Ants leaving the nest lay a "home" pheromone (blue). Ants carrying food lay a "food" pheromone (orange) on the way back. Each ant senses the field with three antennae (left, ahead, right) and turns toward the strongest scent.

Pheromones evaporate, so unused trails fade while busy ones get reinforced. Efficient highways emerge with no planner at all. This indirect coordination through the environment is called stigmergy.

Try this: Left-drag to paint food far from the nest, right-drag to erase it, and watch new trails form.

Open Ant Colony & Pheromone Trails →

Obstacle Avoidance

Obstacle Avoidance — interactive simulation
Generation 2: an evolution of Steering Behaviors

A wandering vehicle needs to look ahead. Each frame it projects a feeler along its velocity (longer when moving faster) and checks whether that line passes too close to any obstacle. If it does, it steers sideways, away from the obstacle's centre, with a strength that grows as the obstacle gets closer.

A separate containment force keeps vehicles inside the walls. Combining behaviours by weighted sum is Reynolds' key insight: complex navigation from simple, independent urges.

Try this: Click to add obstacles (right-click removes them). Try to build a maze they must thread through.

Open Obstacle Avoidance →

Physarum Slime Mould

Physarum Slime Mould — interactive simulation
Generation 2: an evolution of Flow Field Following

A single-celled slime mould can find the shortest path through a maze. Jeff Jones' 2010 model captures it with very simple agents. Each one deposits a chemical trail, senses the trail with three sensors ahead of it, and turns toward the strongest scent. The trail map then diffuses (blurs) and decays.

Tens of thousands of these agents self-organise into living, flowing transport networks that keep reshaping themselves. It is the flow field and ant colony ideas taken to their extreme.

Try this: Try sensor angle 1.0 with rotation 0.5, then 0.2 with 0.6. Tiny parameter changes create completely different networks.

Open Physarum Slime Mould →

Crowd Evacuation

Crowd Evacuation — interactive simulation
Generation 2: an evolution of Flocking (Boids)

Flocking used separation to keep birds apart. In a crowd that same force becomes personal space, and when everyone heads for one exit it produces jams, arches around the door and stop-and-go bursts. This is Dirk Helbing's social force model in miniature: seek the exit, keep your distance from others, and avoid the walls.

A counter-intuitive finding is that a pillar placed just in front of the exit can make evacuation faster, because it breaks up the pressure arch that blocks the door.

Try this: Run with the pillar off and on, and compare the evacuation time shown in the status panel.

Open Crowd Evacuation →

Phantom Traffic Jams

Phantom Traffic Jams — interactive simulation
Generation 3: an evolution of Path Following

Cars on a ring road follow the car ahead using the Intelligent Driver Model. Each driver accelerates toward a desired speed and brakes to keep a safe gap that grows with speed (the time headway). Every driver behaves sensibly.

Yet above a critical density, one small tap of the brakes amplifies backwards through the line into a stop-and-go wave that travels against the traffic: a jam with no cause. Japanese researchers reproduced exactly this with real cars on a circular track in 2008.

Try this: Press "Brake one car" with 25 cars, then with 45. Only the dense road jams.

Open Phantom Traffic Jams →

Wolves, Sheep & Grass

Wolves, Sheep & Grass — interactive simulation
Generation 3: an evolution of Predators & Prey

Add a third level to the food chain. Grass grows back on a timer, sheep wander and eat grass for energy, and wolves wander and eat sheep. Every move costs energy. Animals with enough energy may reproduce, splitting their energy with the offspring, and animals out of energy die.

This classic agent-based model (from NetLogo) produces the same population cycles as differential equations, but with noise, spatial patches of overgrazing, and the very real possibility of extinction.

Try this: Make grass regrow slowly and watch the sheep population become limited by food rather than by wolves.

Open Wolves, Sheep & Grass →

Termites Building Piles

Termites Building Piles — interactive simulation
Generation 3: an evolution of Ant Colony & Pheromone Trails

Mitchel Resnick's termites follow two rules. (1) If you're empty-handed and bump into a wood chip, pick it up. (2) If you're carrying a chip and bump into another chip, put yours down next to it. That's all: there is no plan and no communication.

Yet scattered chips gather into fewer and bigger piles, because a bigger pile is a bigger target, so it collects chips faster than it loses them. Like the ants' trails, this is stigmergy: the environment itself is the memory.

Try this: Speed it up and watch the pile count fall over time.

Open Termites Building Piles →

Evolve them into something new

Several of these are already evolutions: Path Following grew out of Steering Behaviors; Predators & Prey grew out of Flocking (Boids); Ant Colony & Pheromone Trails grew out of Flow Field Following; Obstacle Avoidance grew out of Steering Behaviors. In Labs you can take any of them a generation further: press Evolve this, get suggestions for what the next version could add, and build the one you like — or combine two or three simulations into one system.

Make your own simulation →
Pick autonomous agents as a concept, choose an art piece, game, explainer or experiment, and Labs suggests ideas and builds the one you choose.

Open Labs →

More from Labs