Science lab / collective motion

Boids: a flock made from local rules.

Add agents, draw obstacle walls, tune the behavioural weights, and watch a crowd form streams and clusters without a leader directing it.

Updated

Brief field note

Why a few rules can look like intention

Boids were introduced by Craig Reynolds in the 1980s as an artificial life model for flocking motion. The idea is intentionally modest: each agent only reacts to nearby neighbours, yet the group can form streams, clusters, waves, and sudden turns that look coordinated from a distance.

The classic version is built around three steering tendencies. Separation keeps agents from crowding each other. Alignment nudges each agent toward the average heading of nearby agents. Cohesion pulls an agent toward the local centre of mass. No agent understands the whole flock. The global behaviour appears because many small local adjustments keep feeding back into one another.

Boids makes emergence visible: coordinated-looking group behaviour arises without central command. Computer graphics and interactive simulations often extend the model with rules for obstacle avoidance, goals, predators, terrain, or boundaries.

About this simulator

This version keeps the flock inside a bounded canvas, lets you draw obstacle walls, and lets you inject new agents while the simulation is running. Use the controls to push the flock toward tight schooling, loose wandering, obstacle-dodging streams, or chaotic swirls.

References

Updated ยท factual and copy review

Deep instrument

Flocking workbench

Draw obstacle walls or add new agents directly into the simulation, then tune the local rules to see how the flock adapts.

The outlined agent exposes its perception ring, dashed separation range, neighbour links, local centre, and average heading.

Flock running

Under the hood

The Mathematics Used in This Simulation

Updated

This is an agent-based steering model. Each boid estimates local neighbours inside a perception radius, combines steering contributions, caps its speed, and then advances its position. Agents update in sequence within each animation frame.

Local steering

Δv = wsS + waA + wcC + woO

Separation points away from nearby neighbours, alignment points toward their average velocity, cohesion points toward their average position, and obstacle avoidance points away from the closest point on a wall segment.

Motion update

vt+1 = clamp(vt + Δv, vmax)

xt+1 = xt + vt+1

Here S, A, C, and O include the implementation's steering scales, and the w values are the control weights. Separation, alignment, and avoidance use a scale proportional to the speed limit; cohesion has its own scale. The combined steering change is not capped, but the resulting velocity is limited to vmax. These are per-frame updates, so the animation rate affects how quickly the flock evolves.

Assumptions and limits

Boids are visual agents, not aerodynamic animals. They have no mass, lift, drag, field of view, reaction delay, or energy budget. Boundaries bounce agents back into the canvas, and drawn walls use geometric proximity rather than physical contact.

Further mathematics

All science experimentsNavigation updated