This model demonstrates a population of fireflies which
synchronize their flashing using only the interactions
between the individual fireflies. It is a good example of
how a distributed system (i.e. a system with many interacting
elements, but no 'leader') can coordinate itself without any
central coordinator.

Each firefly constantly cycles through its own clock,
flashing at the beginning of each cycle and then resetting
the clock to zero once it has reached the maximum. At the
start of each simulation all fireflies begin at a random
point in their cycles (though they all have the same cycle
lengths) and so flashing will occur erratically through 
the population. As fireflies perceive other flashes
around them they are able to use this information to reset
their own clocks to try and synchronize with the other
fireflies in their vicinity. Each firefly uses the same set
of rules to govern its own clock, and depending on the
parameters of the simulation, the population may synchronize
more or less effectively.

Though most species of firefly are not generally known to
synchronize in groups, there are some (for example, Pteroptyx
cribellata, Luciola pupilla, Pteroptyx malaccae) that have
been observed to do so in certain settings. This model
generalizes two main strategies used by such insects to
synchronize with each other (phase-delay and phase-advance
synchronization, as described below), retaining the
essentials of the strategies while downplaying biological 

GO: starts and stops the simulation.

SETUP: resets the simulation according to the parameters set
by the sliders.

NUMBER: sets the number of fireflies to be created.

CYCLE-LENGTH: sets the length of each firefly's clock before
it resets to 0.

NUMBER-FLASHES: sets the number of flashes a firefly must
see in a single tick before its clock resets. 

FLASH-LENGTH: sets the duration, in ticks, of each flash.

DELAY/ADVANCE: sets the synchronization strategy to be used.
0 is phase delay, where upon seeing NUMBER-FLASHES flashes a
firefly will reset its clock to the FLASH-LENGTH tick (just
after a flash would normally occur). This causes the firefly
to synchronize with the next flash of the firefly it is
responding to. 1 is phase advance, where upon seeing
NUMBER-FLASHES flashes a firefly will reset its clock to
zero. This causes the firefly to flash immediately. Under
phase-advance, fireflies can only begin to reset their
clocks during a window which begins two ticks after they
have flashed. This assures that flashes do not get stuck in
a short cycle where they persistenly reset their clocks and
stay lit indefinitely.

All slider settings must be set before pressing the SETUP
button. Changes to the sliders will have no effect on a
simulation in progress.

Using the default settings (number: 1500, cycle-length: 10,
flash-length: 1, number-flashes: 1, delay/advance: 0) notice
how local clusters of synchronization begin to form. See if
you can figure out where each cluster is represented on the 
graph. As the simulation proceeds, try to determine which
local cluster will eventually 'take over' the population.
Did this cluster originally have the highest spike on the

In phase-advance simulations, why do the graphs generally
top off before the peaks reach the entire population?

In this model fireflies cannot reset their cycle when they
are in the middle of a flash. Why was this restriction 

Switch DELAY/ADVANCE between phase-delay and phase-advance
while keeping the other settings steady (in particular,
keep NUMBER-FLASHES at 2). Which strategy seems more
effective? Why?

Try adjusting NUMBER-FLASHES between 0, 1 and 2 using both 
phase-delay and phase-advance settings. Notice that each
setting will give a characteristically different graph, and
some of them do not allow for synchronization at all (for
example, with DELAY/ADVANCE set to 1, contrast
NUMBER-FLASHES set to 1 as opposed to 2). Why does this
control make such a difference in the outcome of the

Changing the number of fireflies in a simulation affects the
density of the population (as does adjusting the size of the
graphics screen). What effect does this have on a simulation?

This model explores only two general strategies for
attaining synchrony in such cycle-governed fireflies. Can
you find any others? Can you improve the existing
strategies (i.e., by speeding them up)?

There are many other possible situations in which
distributed agents must synchronize their behavior through
the the use of simple rules. What if, instead of perceiving
only other discrete flashes, an insect could sense where
another insect was in its cycle (perhaps by hearing an
increasingly loud hum)? What kinds of strategies for
synchronization might be useful in such a situation?

If all fireflies had adjustable cycle-lengths
(initially set to random intervals) would it then be 
possible to coordinate both their cycle-lengths and their

Buck, John. (1988). Synchronous Rhythmic Flashing of
Fireflies. The Quarterly Review of Biology, September 1988,
265 - 286.

Carlson, A.D. & Copeland, J. (1985). Flash Communication in
Fireflies. The Quarterly Review of Biology, December 1985,
415 - 433.