NetLogo-如何使海龟在某些滴答声后死亡 [英] NetLogo- How to make turtles die after certain tick

查看:113
本文介绍了NetLogo-如何使海龟在某些滴答声后死亡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让海龟在某些滴答声后死掉. 我可以用什么程序让海龟在10个滴答声后死掉?

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?

推荐答案

这要视情况而定.您是否希望他们在(个人)生命中的10个滴答声或模拟中的10个滴答声后死亡?

It depends. Do you want them to die after 10 ticks of their (individual) life or 10 ticks of simulation?

 turtles-own [
   birth-tick
 ]

; Note: you can define variables for specific breed if you are using breeds

2.创建它们时,设置他们的出生标记:

create-turtles 1 [ set birth-tick ticks ]

注意:在使用滴答声报告器之前​​,请确保已调用reset-ticks

Note: make sure the reset-ticks is called before using ticks reporter

某个地方(通常在go过程中)调用:

Somewhere (usually in a go procedure) call:

ask turtles[ if ticks - birth-tick > 10 [die] ]

注意:请确保在执行过程中调用ticks

Note: make sure you call ticks in your go procedure

如果您想在10个滴答声后停止模拟

If you want to stop the simulation after 10 ticks call

if ticks > 10 [stop]

这篇关于NetLogo-如何使海龟在某些滴答声后死亡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆