top of page
Screenshot 2025-08-02 141730.png

FSM: Boiding Behaviour & Bee's Algorithm

Project Type
Date
Repository

Game Simulation

Sept 2024

This individual project explores how to implement Finite State Machines in Unity, using Bee's algorithm and boiding behaviour.

The following features were implemented in this project: a beehive simulation where the drones function as bees and the mothership functions as the hive; and a predator-prey simulation where the drones exhibit fear, hunger and hunting behaviours. The bee simulation runs prior to engaging with the Player and the predator-prey simulation happens when the player engages in combat with the mothership. 

The drones are boid agents which use physical parameters such as position, mass, orientation, velocity, maximum force and maximum speed to traverse the game space without colliding with other drones. In this project, the boids’ movement is determined by a cohesive force (draw together herd of drones), its current position and rotation, and whether it is far away from the rest of the drone “herd.” 

The mothership and drones operate using swarm intelligence. Specifically, the mothership uses a version of the bee’s algorithm to delegate jobs to the drones. The bee’s algorithm is a population-based search algorithm that mimics the behaviour of bees when they search for and harvest nectar from flowers. In real life, bees can optimize their food reward using a global random search. The algorithm involves 5 steps: recruitment, local search, neighbourhood shrinking, site abandonment and global search.

Through this project, I have implemented boiding behaviours in the drones. I have learned how the movements of a bee colony can be simulated through code through physical manipulation. I explored and implemented the Bee’s algorithm as showcased by the mothership and drones behaviour. Through this, I explored how bee colonies harvest and search for resources and how this can be simulated in Unity. Finally, a predator-prey model was implemented. This was used to create a simple combat encounter between the mothership/drones and the player dreadnaught.

Diagram of Bee's Algorithm

bees_edited.png

Diagram of Predator-Prey Model for drones

predator-prey_edited.png
bottom of page