Netlogo:如何安装“初始值"特定条件下的递减计时器 [英] Netlogo: How can I install the "initial value" of the decrement-timer with specific conditions
问题描述
当乌龟到达路的尽头(右端)时,我想设置一个递减计时器. (我只想为到达道路左端的乌龟激活减量计时器.)并继续转动减量计时器,直到在指定条件下乌龟死亡为止.递减定时器的设置时间("A")是单独设置的.我编写了以下示例程序.但是该模型不能很好地工作.因为在此示例程序中,如果乌龟在路的右端,则每次滴答时都会继续设置递减计时器的初始值.我想在海龟到达路的尽头时安装减量计时器的初始值.因此,在模型开始时,递减计时器的初始值不能存储到设置"编程空间中.当我在设置"位置安装减量计时器的初始值时,在乌龟到达路的尽头之前,减量计时器的初始值将保留在日志中.我想避免麻烦的日志计数.坦克你.
I would like to set a decrement-timer when the turtle reaches the end of the road (right end). (I would like to activate the decrement- timer only for the turtle that reached the left end of the road.) And keep turning the decrement-timer until the turtle dies under the specified conditions. The setting time ("A") of the decrement-timer is set separately. I made the following sample program. But the model does not work well. Because in this sample program the initial value of the decrement-timer continues to be set with every tick, if turtle is at the right end of the road. I would like to install the initial value of the decrement-timer when the turtle reaches the end of the road. Therefore, the initial value of the decrement-timer can not be instolled into "to setup" programming space at the begining of the model. When I install the initial value of the decrement-timer at "to setup", the initial value of the decrement-timer will remain in the log before the turtle reaches the end of the road. I want to avoid having troublesome counting of logs. Tanks you.
let carright one-of turtles-on patch max-pxcor 0
if carright != nobody [
ask carright [ set count-down A ] ;this is the problem.
ask carright [ set speed 0 ]
ask carright [ set count-down count-down - 1 ]
]`
Jen B,您好,我参考您的示例代码制作了以下示例代码,并对其进行了测试.但是,减量计数器没有移动.如果您给我建议,我会很高兴.
Hi Jen B, I made the following sample code with refering your sample code and tested it. However, the decrement counter did not move. I would be happy if you give me advice.
let onend? one-of turtles-on patch max-pxcor 0
ask turtles-on patch max-pxcor 0
;;In this syntax "ask turtles with onend?" I got an error so I changed it.
[ if-else count-down > 0
[ set count-down count-down - 1 ]
[
set gamma-A precision (random-gamma (α) (β))0
if gamma-A <= 0 [
die
set number-of-turtles number-of-turtles - 1
set number-dead number-dead + 1
]
]
]
ask turtles-on patch max-pxcor 0
;;I got an error in this syntax "Ask turtles - on patch max - pxcor 0 with not onend?", so I changed it.
[ set count-down A ;;This worked properly.
set speed 0 ;;This worked properly.
set color red ;;This worked properly.
set onend? TRUE
]
推荐答案
我仍不清楚您要做什么,但是根据评论讨论,这可能比您的代码更接近.
I am still not clear what you are trying to do, but based on the comments discussion, this might be something closer than the code you have.
turtles-own [onend?] ; note that you will have to set this to false in setup
ask turtles with [onend?]
[ if-else count-down > 0
[ set count-down count-down - 1 ]
[ die ]
]
ask (turtles-on patch max-pxcor 0) with [not onend?]
[ set count-down A
set speed 0
set onend? TRUE
]
这篇关于Netlogo:如何安装“初始值"特定条件下的递减计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!