NetLogo- How to make turtles die after certain tick

偶尔善良 提交于 2019-12-11 12:44:43

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!