我怎样才能在 Netlogo 中推迟一个动作?

How can I postpone action a tick later in Netlogo?

我正在尝试对补丁(代表环境)进行建模。当它的资源 运行 关闭时,它们会以滴答的延迟(滴答 + 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
  ]