Each firefly has an inner clock that charges up and makes it flash. When it sees another flash, it charges a little faster. Over time the clocks pull each other into line, until the whole field blinks together.
Watch the orange line: random sparkle turns into tall, regular bursts as they sync. Set coupling to 0 and they keep their own rhythms forever. Different drummers: when rhythms differ too much, coupling cannot hold them together. With a short vision radius, waves and patches sync first, then join up. Run a sweep across coupling to see time to sync drop as coupling rises. Model: pulse-coupled integrate-and-fire oscillators (Mirollo and Strogatz 1990, SIAM J. Appl. Math. 50, 1645), inspired by Peskin (1975) and Buck (1988) on fireflies. Each firefly has phase φ rising at 1/T_i per second, with T_i = T (1 ± spread) drawn from the seeded random numbers, and charge x = ln(1 + (e^b - 1) φ) / b with b = 3. At φ = 1 it flashes and starts again from 0 (keeping any overshoot within the time step). Every firefly within the vision radius that has not yet flashed in that instant gains charge ε / k (ε the coupling, k how many fireflies it can see, refreshed every 0.25 s as they drift slowly); if its charge reaches 1 it flashes in the same instant (absorption). Synchrony is measured by the Kuramoto order parameter r = |mean of e^(2πiφ)|, sampled every 0.25 s; synced means r ≥ 0.95. Time steps are 1/240 s. Real fireflies (for example Photinus carolinus) also have refractory periods and delays not modelled here. The sweep varies the coupling for 60 s with the current settings, repeating over seeds; time to sync is blank when they never synced. Runs on your device.