🐦 2D Boids — Flocking on a Flat Canvas
A genuine 2D flocking engine: separation, alignment and cohesion computed from a real spatial-hash neighbour search, with draggable weight sliders, obstacle avoidance and a cursor-controlled predator.
The 2D companion to 3D Boids — Flocking: the same Reynolds separation/alignment/cohesion rules, run on a flat plane with a real spatial-hash neighbour search, obstacle avoidance and a cursor-controlled predator.
🔬 What it demonstrates
Emergent flocking from three purely local rules — no boid knows about the flock as a whole, only about the handful of neighbours inside its own perception radius.
🎮 How to use
Drag the weight sliders to reshape the flock live, tick the predator to hunt it with your cursor, and click the canvas in obstacle mode to force the flock to split and reform around a wall.
💡 Did you know?
Because the neighbour search uses a spatial hash grid instead of checking every pair, this simulation stays smooth well past 400 simultaneous agents in a plain 2D canvas.
The 2D companion to 3D Boids — Flocking: a genuine Reynolds flocking engine on a flat canvas. Separation, alignment and cohesion are computed from a real spatial-hash neighbour search (not an all-pairs scan), with draggable weight sliders for each rule, obstacles you click to place that the flock must split around, and a predator that hunts wherever you move the cursor.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install