Phase Diagram of Boids
September, 2014
Boids is a simple model of flocking behavior which has been used to simulate the movements of birds in a flock, fish in a school, etc. Boids is one of the classic examples of emergent behavior, with simple and local rules producing complex global behavior.
Back in 2014 (when I was 15), I wrote a C program for efficiently simulating boids in an arbitrary number of dimensions. My original goal was to experiment with OpenGL through GLFW, but I ended up using the code more for analysis than for visualization. Below is a screencapture of the C program with three species which try to avoid each other:
(Having multiple "species" is nice because it keeps them from all forming into one big static flock, and because it produces nice fission-fusion behavior.)
It gets more interesting as you vary the parameters which determine the behavior of the boids. For example, this figure shows a frame from a simulation where each boid has a random visibility radius, as indicated by the color of the dot:
The blue boids have a lower visibility range, while the red ones have a higher visibility range. You can see how the boids with low visibility range end up in the center, while those with a high visibility range end up on the exterior, presumably because they can see the predators in the center and choose to avoid it.
More generally, the goal was to see how the global behavior of the flock is affected by changes to the parameters of individual agents. I don't have concrete enough results to warrant a proper writeup, but here is one of my working notebooks which shows some initial findings.