Afterglowscreensavers

Firefly Synchrony Screensaver

Firefly Synchrony is a free, in-browser simulation of how fireflies fall into step. Each of hundreds of fireflies flashes on its own slightly different cycle, and whenever one flashes, every neighbour within sight nudges its own clock a little forward. From that single rule the swarm drifts, over a minute or so, from random twinkling into unanimous flashing. Nothing to download, and ESC exits at any time.

Live preview

Firefly Synchrony screensaver — Random twinkling finds a single beat.

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Firefly Synchrony screensaver works

Every firefly carries a phase that climbs from 0 to 1 at its own rate — periods vary by a few percent — and flashes when it reaches 1, dropping back to 0. Left alone, the swarm would twinkle at random forever.

The coupling is the Mirollo–Strogatz rule: when a firefly flashes, each neighbour within the sight radius has its phase pushed forward by an amount that grows with how far along it already is. A firefly that was about to flash anyway is tipped over the edge; one that just flashed is barely moved. That asymmetry is what pulls the population together rather than merely jittering it.

Flashes cascade — one tipping over triggers others — and the cascades merge until a single wave sweeps the swarm each period. The sync meter in the corner is the order parameter, the length of the average phase vector, which climbs from near zero to near one as they lock.

Once fully synchronised for a while, a third of the clocks are scattered at random, so you can watch the swarm find its way back. The fireflies also drift slowly, so who can see whom keeps changing.

The synchronising swarm

Synchronised flashing in fireflies has been reported for centuries: in 1680 the Dutch physician Engelbert Kaempfer described coordinated flashing along a river in Siam. Synchrony is still seen in Southeast Asian species and in North America, where Photinus carolinus in the Great Smoky Mountains flashes in unison. The species involved differ from place to place, and most fireflies do not synchronise.

The mathematics came later. Renato Mirollo and Steven Strogatz published a model in 1990 in which identical oscillators coupled by pulses, each firing nudging the others forward, synchronise from almost all starting conditions. Their model builds on Charles Peskin’s earlier model of the heart’s pacemaker, and they proposed it to explain Southeast Asian fireflies. Such pulse-coupled oscillators are also used for pacemaker cells and crickets.

In the model the sync is a property of the rule alone. Because each firefly here only reacts to neighbours it can see, a large space may settle into several synchronised patches rather than one. Experiments on real P. carolinus show that individuals will try to flash on beat with a neighbouring firefly, or even a blinking LED, so the real insects respond to each other’s flashes.

A worked example

At the defaults — 180 fireflies, coupling 4, sight radius 140 px — the field starts as scattered yellow-green sparks with the meter near 10%. Within thirty seconds you can see pockets flashing together, then the pockets merge, and by a minute the whole screen pulses as one with the meter above 90%. Raise the coupling to 8 and it locks in a quarter of the time; drop the radius to 60 and distant groups stay out of step with each other.

Settings & tips

Frequently asked questions

Do real fireflies do this?
Yes. Whole riverbanks of Pteroptyx fireflies in Southeast Asia flash in unison, and Photinus carolinus in the Great Smoky Mountains do it for a few weeks each summer. Mirollo and Strogatz proved in 1990 that pulse-coupled oscillators like these almost always end up synchronised.
What does the sync meter measure?
The order parameter: put every firefly’s phase on a circle and average the points. If the phases are scattered the average sits near the centre and the meter reads near 0%; if they all agree it sits on the rim and the meter reads 100%.
Will this slow my computer down?
It is tuned to run smoothly on an ordinary laptop. If it feels heavy, raise the Pixel size or lower the speed in the settings; every control takes effect immediately.
Is the Firefly Synchrony screensaver free?
Yes. It runs free in your browser with nothing to download or install, and it keeps working offline once the page has loaded.
How do I exit the Firefly Synchrony screensaver?
Press the ESC key at any time to leave fullscreen and return to the page.
Which fireflies really synchronise?
Certain species, such as some in Southeast Asia and Photinus carolinus in the Great Smoky Mountains, flash in unison. Most firefly species flash individually.
What are pulse-coupled oscillators?
They are units that cycle on their own and nudge each other when they fire. Peskin’s heart pacemaker model and the Mirollo–Strogatz firefly model are examples.
Why might the swarm split into groups?
If each member only sees neighbours within a limited distance, separate regions may lock to different beats before they influence each other.

← All Generative screensavers