2017-10-27 HW

posted Oct 26, 2017, 8:39 PM by Konstantinovich Samuel   [ updated Oct 27, 2017, 1:52 PM ]
Homework: 
Watch Netlogo Video 18,19

Classwork:

Variables 

let
globals
turtles-own

Some things to start with:

0.Some widgets are used to display values!


1.Globals (shared by everyone)
-Score
-Counters (like how many turtles died!)



2. Turtles-own
Any property you like, such as age, shoe-size, favorite-color, etc.

3. Local variables
-Calculate a sum
-store the value for a short time. 


globals [ turtle-deaths ]
turtles-own [ oldx oldy ]

to go 
  every 1 / 30[
    ask turtles[
    fd .1
    rt random 5
    lt random 5
    ]
  ]
end

to setup
  ca 
  cro 200
end

to store
  set oldx xcor
  set oldy ycor
end

to recall
  set xcor oldx
  set ycor oldy
end

to-report calculate-sum-of-xcor
  let sum-of-xcor 0
  ask turtles[
    ;???
  ]  
  report sum-of-xcor
end


to kill-some-turtles
  ask turtles[
    if random 2 = 0[
      set turtle-deaths turtle-deaths + 1
      die
    ]
  ]
end

Comments