You are on page 1of 9

NetLogo CSU

Ashok Prasad (PI) Principle Investigator

Andrew Warnock (Lab Coordinator) Facilitator


Christopher Schaumberg (Doctoral Candidate) Student
Install/Open NetLogo on the PC at http://ccl.northwestern.edu/netlogo/
Later: Visit NetLogo Web
http://www.netlogoweb.org/launch#http://www.netlogoweb.org/assets/modelslib/Sample%20Models/Social%20
Science/Traffic%20Basic.nlogo

Tutorial 1 Step One Move and Setup Turtles

This is the first screen you will see


once opened.

Click the Add tool. To add a setup


button.

``
Click on the white space to the left
of the screen once button is
selected. A button prompt will
come up. Type in the under the
Commands line
Setup
Hit ok

The Setup button will appear red


as seen on the left. There is no
cause for alarm because we have
not added the code for the setup
button yet.

``
Click on the Code Tab above so in
order to add the Setup button code.

Type in the coding space:


to setup
clear-all
end

The formatting should add proper


spacing and change to end to green
and clear-all to blue

``
Click the Check Mark. This makes
sure we dont have errors in our
code and will change from green to
gray if everything is ok.

Click the Interface tab notice that


the Setup button is now black.
This indicated that the code has
been added to the button.

``
Click the Code Tab. Use the zoom
magnifying glass to see how to write
the code on the left.
This time we want to add turtles our
agent base value and set them to
random x and y coordinates.
Type right after clear all before the
end:
create-turtles 50
[
setxy random xcor random ycor
]
This adds 50 turtles or triangles on
the screen. We need to use brackets
when we assign each the
coordinates. [ for opening and
] for closing like a sandwich bun
the meat is your code that goes in-
between.
Click the Check mark to make
sure there are no syntax errors. It
will turn from green to gray.

Next step hit the interface tab.

``
Click on the Setup button we
made.
The turtles now show up in the
center of the display screen as seen
on the left.

Click on the add button. Then


click the white space.
The button tab will appear.
Type under the Commands tab:
go

We are creating a new button to


start the turtles moving.
Under the button check the forever
box and click ok at the bottom.

``
The go button will turn red and a
loop arrows will appear.
Its red because we dont have any
code for the button in the coding
tab. The loop arrows appear
indicating that it will run in a
forever loop until clicked on again.

Click on the code tab. Look to the


left with the zoom magnifying
glass to see the code.
Now type after the end:
to go
ask turtles
[
forward 1
]
end
Next step hit the check mark it
will turn from green to gray.
The turtles will now move forward

``
Click on the interface tab,
Now click on the go button we
made,
The turtles will now move around
until unclicked. They are on a
forever loop.

(Optional step)
Right Click the go button we made
to click edit and the button opens.
Unclick the forever box to see the
turtles move one step at a time.
Click ok at the bottom of the
button.
Hit the go button we made now
Each time you hit go it will move
the turtles one step.

``
(Optional step)
Right Click the go button we made
to click edit and the button opens.
Re-click the forever box to see the
turtles until go is unclicked.
Click ok at the bottom of the
button.
Hit the go button we made now
The turtles move until unclicked.

``

You might also like