Fireflies

Once I had basic swarming behaviors with an efficient lookup algorithm down in 3D, I began to explore piling other biologically-inspired algorithms on top. This simulation adds a pulse-coupled oscillator algorithm to the agent’s behavior. Each agent has an internal clock that triggers a flash at 1 then resets to 0. A flash from a neighbor makes the internal clock jump by a random amount which eventually causes them to synchronize their flashes.

This algorithm is based on how Fireflies sync up in large swarms (subject of the excellent book ‘Sync’ by Steven Strogatz). I added a small refractory period after the flash as well, preferring the “wave” patterns that emerge.

Additionally, a cyclic cellular automaton simulation is also added to the agent’s behavior where the “cells” are the agents themselves. Each agent’s color comes from their “state”, and the state changes based on how many neighbors in a certain neighborhood around it are in other states.

Together these resulted in an interesting and beautiful real-time experience in Unity.

Copyright © '23 Jeff Schofield