问题
I'm having a hard time in making the turtles die after certain ticks. What's a procedure that I could use to let the turtles die after 10 ticks?
回答1:
It depends. Do you want them to die after 10 ticks of their (individual) life or 10 ticks of simulation?
a) Let them live for 10 ticks
1. Declare the birthday (or birthtick) variable at the beginning of program:
turtles-own [
birth-tick
]
; Note: you can define variables for specific breed if you are using breeds
2. Set their birth-tick when you create them:
create-turtles 1 [ set birth-tick ticks ]
Note: make sure the reset-ticks
is called before using ticks reporter
3. Ask them to die
Somewhere (usually in a go
procedure) call:
ask turtles[ if ticks - birth-tick > 10 [die] ]
Note: make sure you call ticks
in your go procedure
b) The end of the living world after 10 ticks
If you want to stop the simulation after 10 ticks call
if ticks > 10 [stop]
来源:https://stackoverflow.com/questions/28593889/netlogo-how-to-make-turtles-die-after-certain-tick