CS 184: Computer Graphics and Imaging, Spring 2024
Bird Flocking Simulation
Euhan Kim, Rohan Gulati, Amogh Maganahalli, Natalie Wei
Introduction
In our proposal, we planned to simulate a flock of birds using the Boids algorithm. We have since created a basic implementation of Boids behavior in C++ with a working GUI. Moving forward, we plan to implement a few other features that we will delve into below.
Our Progress
Our Boids have three attributes: position, velocity, and acceleration. We can compute the total force influencing each Boid using the following equation:
We define an alignment force so Boids move in the same direction. We determine a radius and loop through the Boid’s neighbors to determine their average velocity. We increment the force by the difference in velocities.
We define a cohesion force so Boids stick together. We define a cohesion force. Using the same radius as above, we loop through the Boid’s neighbors and determine their average position. We increment the force by the difference in positions.
We define a separation force so Boids do not collide with each other. We determine a smaller separation radius and loop through the Boid’s neighbors. If a neighbor is located within the radius, we increment the force in the opposite direction by the difference in positions divided by distance squared.
We lastly included interactions between predators and the Boids. We didn’t want the predators to influence the alignment, cohesion, and separation of the Boids, so we computed their movements separately. For each Boid, we took the average location of the closeby predators and added a weighted component to the Boid’s motion away from this position. To simulate the predator’s behavior, we added a weighted component to its motion toward the closest Boid.
We treat the final force as acceleration and update each Boid’s position and velocity based on the change in time.
Our Results
Boids are represented as spheres, with predator Boids being larger. They are contained within a 1x1x1 box and turn smoothly upon hitting a wall. The alignment, cohesion, and separation factors can be adjusted by the user in the GUI, which we adapted from Homework 4.
Only alignment
Only cohesion
Only separation
All forces
With predators
Reflections
We plan to implement more features such as density dependent radii and blind angles, as well as behaviors like leader following and obstacle avoidance. We also want to render Boids as 3D birds, perhaps with animations. Finally, we plan to add more parameters to the GUI like the number of Boids and the number of predators.
Updated Schedule
Resources
We repurposed code from Homework 4 to build our simulation and GUI. We referenced this 2D implementation of Boids for predator avoidance and this paper for basic behaviors.