Skip to content
Chaos
Back

A flock that nobody leads

Craig Reynolds’ boids algorithm: local rules, global patterns.

How it works

Each boid follows three rules and nothing else. Separation: steer away from anything too close. Alignment: turn toward the average heading of nearby neighbors. Cohesion: drift toward the center of the local group. No boid knows where the flock is going; the flock itself is just a side effect.

The result is emergent behavior — complex, organic motion arising from simple local interactions. The flock splits around obstacles, reforms on the other side, swirls into temporary vortices, and streams in ribbons across the canvas. None of this is programmed; it simply happens.

Your cursor is a predator. Boids within range feel a repulsive force and scatter outward, then gradually regroup once the threat passes. Adjust the sliders to shift the balance: more separation produces a loose cloud, more cohesion a tight ball, more alignment a smooth stream.

All experiments →