CS 420/594 — Biologically Inspired Computation
NetLogo Simulation


This page was automatically generated by NetLogo 3.1.4. Questions, problems? Contact feedback@ccl.northwestern.edu.

The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun’s Java site.  General information on the models, including instructions for running them on your own computer, is available from the NetLogo Simulation Information Page.  To download this page, do not use "Save As," but right-click (or on Macs control-click) on this link.  You also need to download the NetLogo program, which you can do by right-clicking or control-clicking this link.

created with NetLogo

view/download model file: Firefly.nlogo


This program simulates the self-organized synchronization of firefly flashing. In the region from India east to the Philippines and New Guinea, and also in the Great Smoky Mountains National Park in the USA, enormous aggregations of fireflies gather in trees and flash in near-perfect synchrony. While different species have slightly different methods for flashing in rhythm, the behavior that is modeled here is governed by the following rules:
- each firefly has an intrinsic flashing frequency, and when left alone it will flash at periodic intervals.
- the flashes are timed by the progressive excitation of a chemical within each firefly; the excitation increases until it reaches a certain threshold, at which point a flash is emitted and the excitation is reset to zero.
- if a firefly senses a certain amount of luminescence from its neighbors, it will reset its excitation to zero in order to flash simultaneously with those neighbors in the future; however, if the excitation is close enough to the flashing threshold, the flash has already been started and will proceed as planned even though the excitation is reset to zero. (The signal to flash is initiated when the excitation is 80% of the way to the threshold value.)


The SETUP button arranges the fireflies randomly within a circle, assigns them random excitation levels, configures the plot to monitor the flashing, and displays a color key. The GO button cycles through time, executing the rules stated above. The NUMBER slider controls the number of fireflies in the simulation. The THRESHOLD slider sets the excitation threshold at which point a firefly will flash and reset its excitation to zero. Because excitation is incremented once per time step, this slider also represents the number of time steps between flashes of an (uninfluenced) firefly. The TRIGGER slider controls the amount of luminescence required for a firefly to reset its excitation prematurely. Each firefly's flash is counted as 100 units of light, and the program assumes that perceived light decreases with the inverse square of the distance from source. The BUFFER slider controls how many time steps are necessary for the flashing signal to evolve and terminate in a flash; if a firefly is triggered to reset its excitation when the excitation is within "buffer" of the threshold, the flash will proceed as planned despite the resetting.

Note: You may need to run this model at one-half speed so that you can see the synchronization taking place.


The cluster of fireflies will often establish two phases of flashing before synchronizing completely; this phenomenon is also observed in the field. If there is a rift of empty space between the two groups (due to a random density differnece), they might never completely coordinate. However, when they do move to complete synchronization, the group flashing a step later often prevails because its flashes have been started by the time it perceives the other group's luminescence. Each of the slider variables affects the simulation; generally, faster synchronization is favored by high numbers, low thresholds, intermediate triggers, and low buffers.


The Fireflies model (in the Model Library) is based on a somewhat different model of firefly synchronization.


Translated to NetLogo from Scott Camazine's StarLogo model firefly.slogo by B.J. MacLennan, 2007-10-17.

Return to CS 420/594 home page

Return to MacLennan's home page

Send mail to Bruce MacLennan / MacLennan@utk.edu

Valid HTML 4.01! This page is www.cs.utk.edu/~mclennan/Classes/420/NetLogo/Firefly.html
Last updated: 2007-10-25.