Flocking Birds - 2D Boids Map

Top and side views of a boids flock with a tracked bird, a predator you can drag, and live order, spacing and group graphs.

Switch to 3D

Presets

Playback

Parameters

Model checks

The science

Three local rules

Each bird sees only neighbours within the perception radius and steers by three rules, as in Reynolds' boids model: separation (move away from birds closer than 4 units, weighted 1/d2), alignment (match the mean neighbour velocity) and cohesion (move toward the neighbours' centre of mass). Each rule gives a steering force F = limit(vdesired − v, Fmax); the weighted sum is added to the velocity each step and the speed is clamped to [3, vmax]. No bird knows the whole flock, yet the flock moves as one.

Measuring order

The polarisation Φ = |Σvi| / Σ|vi| is 1 when all birds fly the same way and about 1/√N for random headings. The graphs also show the mean nearest-neighbour distance (compared with the separation distance) and the number of connected groups (birds linked when closer than 0.6 times the perception radius).

Honest simplifications: the 3D rules are used unchanged, and the top and side views are two projections of the same 3D motion. There is no aerodynamics, no field-of-view blind spot, no inertia beyond the speed clamp and the birds are points; real starling murmurations follow roughly the 6–7 nearest neighbours (topological interaction) rather than a metric radius. The predator is a simple radial push and is not part of the 3D page.

What to try
  • Choose Pure alignment and watch polarisation climb toward 1, then Loose swarm to see it fall.
  • Press and drag on the map to chase the flock with the predator circle and watch the group count change.
  • Raise the perception radius and see when separate groups merge into one.
  • Run the three model checks in the left panel.
Polarisation (alignment order)
Mean nearest-neighbour distance
Number of groups