NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it was made in a version prior to NetLogo 6.0, which NetLogo Web requires.)


This model simulates the interactions of a population of glowworms in a cave where there is no light other than that from other glowworms. The interactions between them cause them to either advance or delay the phase of their daily bioluminescence cycle until they synchronize. The phase-change is based on a phase-response curve derived from laboratory experiments in which individuals were exposed to a 3-h pulse of light under free-running conditions.

Another species of glowworm does not have any known cave populations, instead, they are found in moist, dark forest where they are exposed to the light:dark cycles.


Once the procedure starts, each glowworm looks around and if a glowworm within its visible field is at or near its peak (358-360 degrees) then isee returns a value of 1.
If isee is 1 then a decision is made about whether to advance, delay or stay the same. The degree of phase adjustment is decided by the equation that takes into account the amplitude-modifier value, the vertical-shifter value and the phase-shift value. The PRC equation for Arachnocampa tasmaniensis is derived from a sine fit to the data; the equation for Arachnocampa flava is derived from a 3rd order polynomial fit to the data.


GO: starts and stops the simulation.

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

RADIUS: sets the visual radius of individuals.

MODIFIER: sets the degree of attenuation or amplification of the standard PRC that the glowworms’ apply to their own phase. If the value is low the degree of phase-advance or delay is low and vice versa. A setting of 0.05 is a recommended starting point. Values exceeding … result in faster sync but do so erratically.

The next 4 switches allow you to set up different numbers of individual glowworms and arranged in different ways.

LAYOUT_4_on_A_SQUARE?: sets up 4 larvae arranged in a square formation. The code sets the phases of the 4 individuals to 90, 180, 270, 360.

HUNDRED_IN_A_GRID?: sets up one hundred individuals across the world in a grid pattern. The default code sets their starting phase randomly between 0 and 360 degrees (where 0 degrees is the peak (or acrophase) of each glowworm’s daily bioluminescence cycle. The default setting gives each glowworm a period of 24 h but this can be changed in code (a line of code that gives each larva a randomly chosen period within a specified range is grayed out or by default inactivated).

HUNDRED_RANDOMS?: sets up 100 larvae distributed randomly across the world. Each is allocated a random starting phase between 0 and 360.

LAYOUT_NUMBER_IN_CIRCLE: sets up a number specified in the number slider that sits below these switches.

SPECIFY_NUMBER_OF_RANDOMS: this slider sets up the number specified in the number slider distributed randomly across the world. Each is allocated a random starting phase between 0 and 360.

A number of plots are used to display the progress to synchronization.

SYNCHRONIZATION INDEX: This value is calculated day-by-day. When maximally unsynchronized the value is 0 and when synchronized the value is 1..

PEAKING AGENTS: This is an alternative way to track synchronization. It is a plot of the number of agents that are at their peak (i.e. a phase of 0 degrees) at each tick.

GLOWWORM0 and GLOWWORM1: allows the viewer to see the effect of phase adjustments on these two representative glowworms’ phase. The daily cycle is shown in the form of a sine wave where the upswing crossing of the zero line represents when each glowworm is at its acrophase. The smaller black bars indicate when a glowworm has seen another glowworm within its visual radius at its peak.

TIME OF DAY OF NADIR OF TURTLES 0 – 3: This plot displays the time of day in degrees at which these representative glowworms are at their nadir (180 degrees). The purpose is to show the day-to-day trend in the period, especially when synchronized. An upward slope tells the viewer that the glowworms have a period > 24 h and a downward line shows a period < 24h. It is for display only: sometimes it does not display correctly.

STOP_AT_X_SI: when switch is on, a run will stop when the synchronization Index reaches a set value, displayed live alongside.

STOP_AT_SET_TICKS: when switch is on, a run will stop at the set number of ticks, displayed live alongside.

MODIFIER: this value determines how much change is made at each refrence to the phase-response curve. Higher values cause rapid but ragged synchronization. Low values slow down synchronization.

VERTICAL_SHIFTER: shifts the phase-response curve along the y-axis

HORIZONTAL_SHIFTER: shifts the phase-response curve along the x-axis

VIDSUAL-RADIUS: determines the radius of vision of each agent. If too small, agents can't see others at all and the run is terminated.


First, clusters become synchronized and then the whole field locks into sync.


To follow the process outlined in the results section of the publication, set the radius to 18 and amplitude-modifier to 0.2, then turn on the switch "layout_4_in_a_square?". Make sure the other switches are in the off position. The code sets the phases of the 4 individuals to 90, 180, 270, 360.

Turn off the "stop at x ticks" button and the "stop at set SI" button so that you can see the ongoing synchronization.

Now hit the “go” button.

Watching the color display, you will see the 4 glowworms gradually synchronize. The plots on the dashboard show this process: the SI will gradually climb to 1, the number of peaking agents will climb to the maximum of 4, the sine-wave displays will show two of the glowworms gradually coming into phase with each other. The “time of day of nadir” plot will show their relative advance and delay and their synchronisation.

If you want you can change the code; for example, Figure 4 of the paper shows the process of sync when 3 agents are set on 0 and the phase of the 4th agent is varied. Change the “set phase” values of turtles 0, 1, 2 to, say, 0 degrees and and vary the phase of turtle 3 (note: radius has to be set to at least 10 to allow them to see each other)

Try changing the amplitude-modifier value: low values slow up the process of synchronization but do it smoothly when you observe the sine-wave representation. High values speed it up but do it in a ragged manner with large advances and delays producing abnormally-distorted curves.

Try setting up a non-24 h FRP. To do this first decide your start-up conditions.Go into teh code and inactivate the set period 24 command and instead acvate the set period random-normal 24.5 .5; (tasmaniensis mean and SD is 24.5 .5). The agents now have different starting periods.

Try turning on the "100 in a grid" button (making sure the other startup buttons are off). You can see clusters of glowworms coming into synchronization.

Try creating conditions where glowworms are on the cusp of being able to synchronize and see if you can create runs where rolling patterns emerge. We recommend 100 in grid (make sure the other switches are in the off position), set radius to 8 (a low value slows down sync). Under these conditions, some runs show sweeping bands or swirling patterns among the glowworms due to the individuals having a restricted visual capability; thay can’t see very far so they are restricted to reacting to only the closest neighbours. This is similar to the sweeping bands of firefly flashes seen in some studies. You can change parameters such as the visual radius and the modifier value while the model is running. Start with a low visual radius, and increase it as the model runs and watch the process of synchronization.


You can change the model so that the phase response curve referred to is not from A. tasmaniensis but from a related species, A. flava. It does not synchronize under laboratory conditions or in the field. When its PRC is put into the model, synchronization does not occur.
To implement in code, inactivate tasmaniensis PRC equation and activate flava's equation.

set phase (phase + ( ( (-17.597 - 29.233 * SIN (phase + horizontal-shifter) + 21.397 * COS (phase + horizontal-shifter) - 7.254 * SIN ((phase + horizontal-shifter) * 2) + 8.711 * COS ((phase + horizontal-shifter) * 2)) + vertical-shifter) * modifier)); tasmaniensis' PRC

set phase (phase + (((-0.000020166873981 * (phase + horizontal-shifter) ^ 3 + 0.013002660989270 * (phase + horizontal-shifter) ^ 2 - 3.026077821383480 * (phase + horizontal-shifter) + 232.501180575072000) + vertical-shifter) * modifier)); flava's PRC

You can turn off inter-agent interactions and expose agents to a single pulse of light every 24 h by activating the statement
;ifelse ticks mod 144 = 36 [set isee 1] [set isee 0]; to provide single forcing pulse every 24 h, annul the 2 foregoing statements and replace with this
Alternatively expose to 12:12 LD conditions by activating the statement:
;ifelse remainder ticks 144 < 72 [ set isee 1] [set isee 0]; to register daylight for 12 of every 24 h, annul the 3 foregoing statements and replace with this



Parts of the model were inspired by the Netlogo Fireflies model by Uri Wilensky (1997). Manfred Hartbauer provided the code for calculating the synchronization index.


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Merritt, DJ and Gilchrist, J (2018) NetLogo Glowworm Model.

Please cite the NetLogo software as:

Wilensky, U. (1999). NetLogo. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.


![CC BY-NC-SA 3.0](

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

(back to the NetLogo User Community Models)