You are on page 1of 7

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 2 Turtle Power (Changing a Turtle to a Sprite,


Speed Control )

The last step was


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

``
Type Click on the code tab.
Under the create-turtles 50 and before [
setxy random xcor random ycor
]
Type:
ask patches [ set pcolor blue ]
This will set the background to blue.

On the same line:


Type ;; before [
Type ;; before setxy random xcor random ycor
Type;; before ]
It should look like the left image notice it changes
to gray indicating it is a note.
Any note left on the same line after;; is a comment.

``
Now delete
;; [
;; setxy random xcor random ycor
;;]

Click on the green check mark it will turn gray.


The next step is click interface.

``
Now click on the setup button we made in the
previous tutorial. The background should turn to
blue.

The next step click code

Type before the to setup breed [Fishs Fish] hit


enter which will make it on a new line.
Note we added an agent and gave a turtle a given
breed.
Hit the check mark and it will turn from green to
gray.
The next step is to click on the interface tab.

``
Click on the button and select slider.
In the white space to the left of the screen click to
get a slider button created.

The slider box will appear. In the global variable


Type InitialFish
Change Maximum to 10
And value to 1
Click ok
The slider should appear as a box that can be
moved back and forth between 1 and 10.
Next step click on the code tab

``
Delete or comment out create-turtles 50
After ask patches [set pcolor blue ] and before the
end
Type:
set-default-shape Fishs "fish"
create-Fishs InitialFish
[
set color yellow
set size 5
]

Add comments where needed


After but on the same line- add comments so others know
what your code is doing
breed [Fishs Fish] type ;; Agent Any turtle of the given breed

The breeds agent let us create a turtle and give it a specific


breed, for example breed could be fish, shrimp, plants, or
trout- each can have different behavioral or motion code.
ask patches [ set pcolor blue ] ;; background color
set-default-shape Fishs "fish" ;; fish sprite
create-Fishs InitialFish ;; for the slider
set color yellow ;; color Fish Yellow

set size 5 ;; easier to see size large

``
Click on the check mark to check and upload the code
Click on the interface tab
slide the fish to 3 fish
Hit setup
Click on the go button
While its down it will move the fish around
While go is pressed go to the top middle of the page
Slide the normal speed to slow the process down slide
speed to slow. The fish will move in the tank slowly
now.

``

You might also like