All models

MathPets source

Fireflies

pet clocksin-radius queriesstaged pet stepsmodel memorytorus motion
Open in VS Code

Southeast Asian fireflies famously gather in riverside trees and flash together, a puzzle John Buck documented in the field and that Mirollo and Strogatz later explained with pulse-coupled oscillators. No conductor is needed: each insect only reacts to the flashes it can see.

Here every firefly wanders the torus carrying a clock that ticks up each step and fires a two-tick flash when it wraps. Seeing a flashing neighbor within sense-radius nudges a dark firefly's clock forward, so laggards catch up to early flashers. From random phases, waves of near-simultaneous flashing emerge over a few hundred ticks.

board · 732 × 540grid · on