Download NetLogo 4.1.3 User Manual - Center for Connected Learning and

Transcript
NetLogo 4.1.3 User Manual
observer are.)
Patches have coordinates. The patch at coordinates (0, 0) is called the origin and the coordinates of
the other patches are the horizontal and vertical distances from this one. We call the patch's
coordinates pxcor and pycor. Just like in the standard mathematical coordinate plane, pxcor
increases as you move to the right and pycor increases as you move up.
The total number of patches is determined by the settings min-pxcor, max-pxcor, min-pycor,
and max-pycor When NetLogo starts up, min-pxcor, max-pxcor, min-pycor, and max-pycor
are -16, 16, -16, and 16 respectively. This means that pxcor and pycor both range from -16 to 16,
so there are 33 times 33, or 1089 patches total. (You can change the number of patches with the
Settings button.)
Turtles have coordinates too: xcor and ycor. A patch's coordinates are always integers, but a
turtle's coordinates can have decimals. This means that a turtle can be positioned at any point
within its patch; it doesn't have to be in the center of the patch.
Links do not have coordinates, instead they have two endpoints (each a turtle). Links appear
between the two endpoints, along the shortest path possible even if that means wrapping around
the world.
The way the world of patches is connected can change. By default the world is a torus which means
it isn't bounded, but "wraps" -- so when a turtle moves past the edge of the world, it disappears and
reappears on the opposite edge and every patch has the same number of "neighbor" patches; if
you're a patch on the edge of the world, some of your "neighbors" are on the opposite edge.
However, you can change the wrap settings with the Settings button. If wrapping is not allowed in a
given direction then in that direction (x or y) the world is bounded. Patches along that boundary will
have fewer than 8 neighbors and turtles will not move beyond the edge of the world. See the
Topology section for more information.
Procedures
In NetLogo, commands and reporters tell agents what to do. A command is an action for an agent
to carry out. A reporter computes a result and report it.
Most commands begin with verbs ("create", "die", "jump", "inspect", "clear"), while most reporters
are nouns or noun phrases.
Commands and reporters built into NetLogo are called primitives. The NetLogo Dictionary has a
complete list of built-in commands and reporters.
Commands and reporters you define yourself are called procedures. Each procedure has a name,
preceded by the keyword to. The keyword end marks the end of the commands in the procedure.
Once you define a procedure, you can use it elsewhere in your program.
Many commands and reporters take inputs -- values that the command or reporter uses in carrying
out its actions.
Examples: Here are two command procedures:
94
Programming Guide