Software Engineer
Loading posts...
Feel free to contact me at kanishksachdev@gmail.com
A flock of starlings wheeling through the sky looks choreographed, but no bird is in charge. In 1986 Craig Reynolds showed that the whole shifting, swirling thing emerges from each bird following just three local rules about its nearby neighbours. He called his simulated birds boids.
Every triangle below is a boid, coloured by the direction it is heading. Move your cursor (or finger) through them to scatter or gather the flock, try a preset, or pull the sliders and watch the character of the swarm change.
Move your cursor (or finger) over the flock to scatter it.
Each boid looks only at the neighbours inside its sight radius, then nudges its own velocity a little toward the average of three urges:
That is the whole algorithm. Crank cohesion up for a tight ball, alignment up for streaming rivers of boids, or separation up for a nervous, spread-out crowd. The trick that keeps it fast even with hundreds of boids is only ever checking neighbours in the same patch of space, not the entire flock.
Based on Craig Reynolds' original boids work.