Lab/Canvas 2D

Boids Flocking

Craig Reynolds' 1986 flocking algorithm — I rebuilt it with a spatial hash grid for O(n) neighbor lookups instead of the naive O(n²) approach, added proportional boundary steering that scales to any viewport, and tuned the separation/alignment/cohesion weights for tighter, more natural flock formations. Move your cursor to scatter them.

How to interactMove cursor to scatter the flockWatch them regroup autonomouslyThree rules: separate, align, cohere
Tech:Canvas 2D