M. Drew LaMar
March 27, 2020
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: