A simulation that replicates the flocking behavior seen in nature, similar to how birds and fish move cohesively in groups.
Run : https://boids-flocking.vercel.app/
View related post on Twitter , LinkedIn
This core of this simulation is based on Steering Forces.
Basic Flocking Rules Include
- Separation: Boids steer away to avoid bumping into each other
- Alignment: Boids steer in the same direction as nearby boids.
- Cohesion: Boids steer towards the center of the group.
Predator-Prey Dynamics: A predator chases one group of boids while the others avoid it if it gets too close. I also gave predator ability to shoot projectiles and show explosion with some simple particle effect.
I wanted it to look more cool so I made the camera follow predator in a cinematic way and added unreal bloom effect.
Original Boids Model by Craig Reynolds
SubOptimal Engineer Three.js Playlist
Nature of Code - Autonomous Agents