Courses/CS 461/Winter 2006/Robert Lai/Homework 1
From CSWiki
< Courses | CS 461 | Winter 2006 | Robert Lai
[edit] Homework 1
; Name: Robert Lai
; Classes: CS461
; CIN: 219022282
; File name: Homeword_1.nlogo
to setup
; clear all turtles and patches
clear-all
; run the procedure setup-turtles
setup-turtles
; preform the changing to all the patches
ask patches
; set the background color of the display
[set pcolor 0]
end
to setup-turtles
; create 100 turtles
crt 100
ask turtles
; move 10 steps forward in the direction of its heading with the size of the turtles
[fd 10]
end
to move-turtles
; every turtles that created before should execute fellow the command within the box "[...]"
ask turtles [
; turn to the left 45 degrees
lt 45
; move 1 steps forward in the direction of its heading with the size of the turtles
fd 1
; changing the color for every time the turtles move
set color (color - 1)
]
ask patches[
; wait for 2 seconds for every time the move of the turtles and then change the background color
wait 0.25
set pcolor (pcolor + 1)
]
end
to go
; run the procedure move-turtles
move-turtles
end

