Flashing

Certain types of fireflies will synchronize their flashing. (Tennessee Fireflies.)

In this simulation each firefly (turtle) has a cyclical clock. During a certain period the firefly flashes yellow, otherwise it turns dull gray. Initially, the clocks aren't synchronized, so neither is the flashing.

During a brief period in the dark part of the clock's cycle, the firefly counts the number of flashing neighbors. If it is above some threshold, the firefly will reset its clock to some fixed point in the cycle.