Preview - Animal Behavior Lab (Isopods)

A not-so-sneak peek into the code behind the model

Here's a version of a fire model that a team of researchers tried to modify, but it does not run as they expected. In fact, it's totally broken and does not run at all.

Can we help them fix it?


Please answer the questions below.

Setup the model. What is the mistake (or what you might hear people call a 'bug') in the researcher's model?

You probably noticed that after you press 'setup', you see blue colored trees. Maybe the bug in the code has something to do with the color of the trees. Maybe the color of the tree is set to 'blue' instead of 'green' by mistake.

Click on the bar that says 'NetLogo Code'. You can find it below the big square in the model.

Where does it say 'blue' in the code? And there does it say 'green' in the code?

You can fix that bug! Go to a line that say 'blue' where it should have been 'green'. Change the code.

Click on "Recompile code" and run the model again. Does it work now?

Can you explain why it did not work before?

These computational models, written in NetLogo, allow users to change the code and observe the effect of those changes. That is a very important feature of these Emergent Systems Microworlds: you can play with them and manipulate them by changing the parameters such as 'density' or by changing the code to see how the "microworld" you see is affected.

Now go back to the code and try to read some of it. The NetLogo language is designed to be easy to understand for humans. Pick a line in the code and paste it below. Try to explain how it affects the way the model would behave. 

For example, 

set initial-trees count patches with [pcolor = green]

This line sets a value for a variable 'initial-tree' by counting the patches that have pcolor (patch-color). This line is written in the NetLogo language that the NetLogo compiler understands.


These notes will appear on every page in this lesson so feel free to put anything here you'd like to keep track of.