← 🤖 Algorithms & AI
Drag sliders to reshape the flock · click canvas to drop an obstacle

🐦 2D Boids — Flocking on a Flat Canvas

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.