M. Drew LaMar
October 14, 2016
The model was designed to explore questions about virtual corridors. Under what conditions do the interactions of butterfly hilltopping behavior and landscape topography lead to the emergence of virtual corridors, that is, relatively narrow paths along which many butterflies move? How does variability in the butterflies’ tendency to move uphill affect the emergence of virtual corridors?
Question: What are the explanatory variables and processes and what is the system output we are interested in?
ask
, set
, let
, create-turtles
, ifelse
, and one-of
.Discuss: When you click the new setup button, why does NetLogo seem to color the patches in spots all over the View, instead of simply starting at the top and working down?
Answer: NetLogo always, by default, goes through turtles and patches in random order. This is an attempt to remove a possible confounding process -
agent ordering . This is an example ofasynchronous updating.
This is the programmers “Do as I say and not as I do!” Think of commenting as taking notes in your learning.
“Comments are needed to make code easier for others to understand, but they are also very useful to ourselves: after a few days or weeks go by, you might not remember why you wrote some part of your program as you did instead of in some other way.”
if
or ifelse
statements (i.e. after closing using ]
character);-----------
to separate procedures in long programs.show (word elev1 " " elev2 " " elevation)
The point is to make your code readable and understandable, so some caveats:
globals [ ]
chunk of code. I would also put an additional comment at the end stating it is on the Interface. For example: globals
[
; q ; (Interface Slider) Probability that ...
]
setup
procedure. If you choose to comment and not remove, I would also put the same comment from the globals
chunk in here as well. For example:to setup
[
; set q 0.2 ; (Interface Slider)
]
Tips to reduce probability of getting stuck and increase probability of getting unstuck.
Check
button) and runtime (using Go
button) errors, and verify and validate code (i.e. is it doing what it is supposed to do?) For verification and validation:
Step
button that steps through the program one tick at a time.show
statements throughout your code.Tips to reduce probability of getting stuck and increase probability of getting unstuck.