Now that you've got a taste of how the NetLogo interface works...
we're going to spend some time talking about the basic objects of NetLogo.
And of course one of the main basic objects is the turtle...
the basic agent of the model.
So the first thing we should do is create some turtles.
What you have here is a blank model that I've just opened up,
and this is what you get when you open up NetLogo normally,
and what I can do is go down to this space that says 'observer'...
underneath the 'Command Center'...
and here I can type commands in that will go straight to NetLogo.
So one of the most basic commands and one of the first commands you'll often write...
is create-turtles. And what create-turtles does, as you might expect, is create turtles,
and you have to give it the number of turtles,
so I can create 100 turtles
and when I do that, you'll see that in the middle of the world..
there are 100 little triangles piled up on top of each other.
It might not be obvious that there are 100 little triangles there,
so what I can do is, I can talk directly to the turtles,
There are two ways to do this in NetLogo.
One of them is much more common, but let me show you the less common way...
which is - this little 'observer' thing is actually highlightable,
and I can instead select 'turtles',
and so now, rather than talking to the observer, which is the all-seeing 'deity',
I'm now talking directly to the turtles.
And I can tell the turtles to all go forward 10 steps,
And when I do that, as you can see, we spread the turtles out around the world,
and now you might be able to see that there's 100 of them...
they're all pointing in slightly different directions,
and they are have slightly different colors, to differentiate them.
That's the less common way of talking to the turtles.
The more common way - because it's the way we do it from the code tab -
is we ask the turtles to do something.
So I can ask turtles, and then I have to use these square brackets...
to tell it the message I want to ask the turtles.
I can ask the turtles, for instance, to go back 5 steps...
and when I do that you can see they go back 5 steps.
You're going to be using ask turtles a lot
because ask turtles is the basic way that NetLogo's observer communicates with turtles.
In addition to having them go forward and back...
I can also have them go left 90 degrees...
and I can have them go right 90 degrees...
or any arbitrary number, so right 9 degrees, for instance.
Then I can put these commands all together
and I can ask them to repeat them, to put together a set of coordinated movements.
So, for instance, I can ask the turtles to repeat 4 times a particular step...
in this case, let's have them go forward 10, right 90 degrees...
and you didn't see anything, because, if you think about it, if I repeat 4 times...
'forward 10 right 90 degrees' what I'm doing is drawing a box,
and that means the turtles are returning to the same place.
However, as we learned in the previous talk we can use the speed slider...
to control the speed at which they do this and then maybe we could see them.
So I turn the speed slider down, and now, sure enough...
you can see each individual turtle doing the actions that we asked it to do.
It'll take quite a while if you leave it at this slower speed, so we'll speed it up.
We've talked about basic commands for the turtles.
Turtles also have a variety of properties
For instance, they have the color that you can see,
and we can ask the turtles to change their color,
we can set color blue for all the turtles, for instance...
oop! - this is a nice notion - I created an error here...
I left a bracket out...
and NetLogo will tell me what that error is...
it will tell me there is no closing bracket for this open bracket...
So I put the bracket in, and once I do that it works.
I can also ask the turtles to change their size,
the default size is 1, I can change it to 2, so I can make them all bigger.
And I can change where they are located in the world
They have an x coordinate (xcor) and a y coordinate (ycor)
And rather than setting their xcor and ycor to particular values...
I'm going to set them to random values.
So I can set their xcor to a random-xcor and their ycor to a random-ycor,
random-xcor and random-ycor are built-in NetLogo primitives...
that generate a random value for those particular settings.
That gives you some basic introductions to the properties,
if you want to find out more about the properties...
you can right-click (or control-click on a Mac) on any of the different turtles,
and if you go down there's a little 'turtle menu 92', which will highlight that turtle,
here, '92' specifies that specific turtle,
and we can inspect the turtle, and we can see that particular turtle's properties,
so you can see '92' - its identifier, its color, its heading, xcor, ycor, shape...
and we'll go over all these as we continue through the model discussions.