Understanding Agents in NetLogo cont...
In NetLogo, there are three different types of agents: turtles, patches, and the observer. All three are capable of carrying out their own activity, all simultaneously.
Here come the Turtles
Turtles are agents in the traditional sense. They are the “beings” that move around in the world (the CA grid of patches). But why are they called turtles? We refer to the agents in NetLogo as turtles as a form of tribute to the Logo programming language which NetLogo is derived from. In the traditional Logo programs (like Microworlds Logo, Terrapin Logo, or UCB Logo), the programmer controls a graphical “turtle” on the screen. The turtle responds to commands or procedures. In some early implementations of Logo the turtle was actually a physical object - a kind of robot – which moved around on the floor in response to commands given to it by a computer.
In most Logo programs, there is usually one, two, or maybe a handful of turtles on the screen. NetLogo is different in that there can be hundreds or even thousands of turtles on the screen at the same time. All responding to the same commands simultaneously. So while Netlogo’s agents retain the name of “turtles” (and you will see reference to Turtle Commands in the User Manual), they really are just agents – and you can think of them as a sort of shape-shifter. In one model they might represent actual turtles, in another they could be people, or fire, or bees, or termites. You get the picture.
When NetLogo starts up, there are no turtles yet. The observer can make new turtles. Patches can make new turtles too. (Patches can't move, but otherwise they're just as "alive" as turtles and the observer are.)
Patches Turtles “live” in a two-dimensional world of patches. The world is two dimensional and is divided up into a grid of patches. Each patch is a square piece of "ground" over which turtles (the agents) can move.
Patches have coordinates. The patch in the center of the world has coordinates (0, 0). 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 screen-edge-x and screen-edge-y. When NetLogo starts up, both screen-edge-x and screen-edge-y are 17. This means that pxcor and pycor both range from -17 to 17, so there are 35 times 35, or 1225 patches total. (You can change the number of patches by editing NetLogo's Graphics window.)
BOX: Turtles have coordinates too: xcor and ycor. A patch's coordinates are always integers, but a turtle's coordinates can have decimals. For speed, NetLogo always draws a turtle on-screen as if it were standing in the center of its patch, but in fact, the turtle can be positioned at any point within the patch.
The world of patches isn't bounded, but "wraps" -- so when a turtle moves past the edge of the world, it disappears and reappears on the opposite edge. 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.
Are Patches agents? In many models, patches are simply the world on which the turtles live. The turtles interact with one another – and can interact with the patches. Yet we can also think of the patches as agents too. While they can’t move, they can change their “state” based upon rules. Patches can change color; they can possess variables (or data specific to each patch); they can create turtles; they can kill turtles.
Who is this Observer? The observer doesn't have a location -- you can imagine it as looking out over the world of turtles and patches. It can be used to “ask” the patches or the turtles to carry out specific commands. It also collects data from models – and can create graphical plots and monitors of what is going on in the model.
|