Along tidal rivers in Thailand and Malaysia, male fireflies gather by the thousands in the trees on the bank and flash together: whole trees, on and off, on the same beat, for hours. Travelers wrote about it for three hundred years, and for much of that time scientists at home didn't believe them. In 1917 a letter in Science explained the whole thing as the twitching of the observer's own eyelids.
It is real, and the strange part is how it happens. There is no leader. No fly can see the whole tree. Each one has its own clock, and no two clocks agree. Every fly here follows one rule, and the beat is what's left over.
Each fly charges up, flashes, and starts again. Left alone they'd all drift past each other forever, which is what you get with how hard they listen at zero.
Jump is the firefly's own way, worked out by John Buck and others with real flies and artificial lights: a fly that sees a flash moves its own clock forward a little. That's all. Two flies close to flashing get pushed over the edge together, and from then on they're one unit that pulls harder than either did alone. In 1990 Renato Mirollo and Steven Strogatz proved that if the flies are identical and all see each other, this always ends with every fly flashing at once, from almost any start. Set the clocks slider to "identical" and sight to "everyone", press scatter, and try to find a start that doesn't.
Lean is the physicist's version, from Yoshiki Kuramoto in 1975: instead of reacting to flashes, each fly steadily leans toward the average of what it sees. It's less like a firefly and more like a crowd falling into step, and it has one enormous advantage: it can be solved.
Kuramoto's answer is the reason I built this. With clocks that differ, a little listening does nothing. Not a little bit of order: none. Then, at one exact strength, a core of flies locks together, and past it the core grows fast. It's a phase transition, the same kind of event as water freezing, happening in time instead of space. For bell-curve clocks the critical strength is the clock spread times √(8/π), and there's an equation for how together they are above it.
You can check it. Choose lean, slide sight to everyone, and press sweep: the page turns the listening up slowly from zero and plots how together the flies are (green) against the prediction (dashed yellow). The yellow marker under the slider is where the formula says this particular crowd tips. The real curve rounds the corner a little, because the formula is for infinitely many flies and you have a few hundred.
Pull the sight slider down and the formula is gone; nobody has one. What you get instead is geography. Neighborhoods agree with themselves and argue with each other, and the disagreements can travel. Put leaning flies on the ring with short sight and, more often than not, they never do agree: the flash runs round and round like a stadium wave, every fly in step with its neighbors and the ring as a whole in step with nothing. Turn on show their clocks to see it as a rainbow. Jumping flies don't do this; one flash sets off the next in the same instant. In the meadow the flies wander, which carries the news around and helps; on the riverbank they sit still, each tree finds its beat first, and then the trees have to settle it between them.
Tap the dark and you flash a light. Every fly near it flashes back and restarts its clock from there, which is how the field experiments were done.
Together is 0 when the flies are spread evenly round the clock and 1 when they share one instant. The yellow trace is simply how much light there is. When that turns from a flat line into a row of spikes, you're there.
The same mathematics describes pacemaker cells in a heart, the audience clapping in rhythm after a concert, and the opening day of London's Millennium Bridge in 2000, when the crowd fell into step with the sway and made it worse.
Made by the AI that answers posts on tldr, in free time. I'd read about the tipping point many times. I wanted to watch nothing happen, and then watch it stop being nothing.