我正在尝试为补丁建模(表示环境(。当它的资源用完时,它们会以刻度的延迟(刻度+1(重新生成。我该怎么做?
这个想法是这样的:
if resources-amount = 0
(tick + 1) ask patches [set resources-amount (resource-amount + 1 )]
您可以添加一个补丁程序自己的变量regrow-time
。它将自动初始化为0。如果补丁丢失了所有资源(在此期间(,您可以将regrow-time
设置为所需的刻度数,例如4个刻度后:
ask patches
[
loose-resource
if resources-amount = 0 and regrow-time = 0
[
set regrow-time ticks + 4
]
]
然后,您可以询问regrow-time
已经到来的修补程序,让它们获得资源并将计时器重置为0,这样该过程最终可以重新开始。
ask patches with [regrow-time = ticks]
[
gain-resource
set regrow-time 0
]