Greg Peterson

Boids Algorithm and Simulation

Project Overview

Boids are an algorithm that simulate the movement pattern of flocking birds. I decided to take on this project because I was really interested in a video made by Sebastian Lague on boids. Although his approach of the boids algorithm was made in Unity, I decided to make mine a plugin in Unreal Engine 5.

Technical Details

My goal for this project was to be able to handle as many boids as possible. I first analyzed the video's implementation of the algorithm and recognized that the code for updating the boids' positions was slow because it used Unity's equivalent of the Tick() function for every boid. Additionally, the code used an inefficient way of tracking collisions. Although it was deterministic and caused the movement of the boids to be predictable, I believed that a faster and more randomized approach was more desirable for my goals, and the randomness could even make the simulation look better.

After analyzing the code and coming up with a plan for my implementation, I went ahead and created it as a plugin in Unreal Engine 5. My machine can handle 2,000 boids at 60 FPS. However, there are still some improvements that can be made. I could use a more efficient spatial partitioning algorithm like an octree to further increase the speed of collision detection. Additionally, my implementation has options for multithreading because calculating the position of the boids and setting their positions happen independently from each other.

Tools Used

Unreal Engine 5
C++
Algorithms
Performance Analysis