This repo is a demonstration of implementing a boids simulation using some modern (as of 0.15) bevy concepts such as observers, required components, as well as some good practices such as system sets, generic systems, etc.
Boids is a simulation of flocking behaviors found in birds, fish, and herd animals, first described by Craig W. Reynolds in 1987. It uses three simple principals that a flocking entity (boid) can use to create emerging complex behaviors resembling a school of fish/flock of birds. The principles are:
- Separation: Avoid bumping into your flockmates
- Alignment: Try to go the same-ish way as your flockmates
- Cohesion: try to stick with the group
This creates a seemingly complex behavior that emerges from many boids following these rules with the information they're given. Each boid is limited by it's vision range.
This repo aims to reproduce behaviors listed in this paper: Steering Behaviors For Autonomous Characters, which covers more behaviors, such as seeking out a target, obstacle avoidance, roaming, etc.
The boids algorithm itself was fist described here: Flocks, Herds, and Schools: A Distributed Behavioral Model
After setting up a basic rust environment (mainly cargo
), use cargo run --release
to watch the simulation unfold. You can control the simulation with the
settings floating menu, and use Shift + click to spawn a target for the boids to follow around. You can also drag the target.