如何在 NetLogo 中将 运行 出 "wealth" 后停止自动收报机

How to stop the ticker once turtles run out of "wealth" in NetLogo

**> Hi, I'm new to NetLogo and this is my 1st model. Basically, I would

like the 'ticker' to stoprunning once the turtles have spent their 'wealth'. I have tried looking through the various models if I can copy/adapt some of the codes but to no avail. Appreciate any help that I can get. Thanks**

turtles-own [wealth]
patches-own [income]

to setup
  ca
  setup-turtles
  setup-patches
  reset-ticks

end

to setup-turtles
  create-turtles 1000
  ask turtles
  [
    set shape "person"
    set size 1
    setxy random-xcor random-ycor
    set wealth 100
  ]
end

to setup-patches
  ask n-of 4000 patches [ set pcolor green ]
end


to go
  move-turtles
  spend
  tick
end

to move-turtles
  ask turtles [
   ifelse wealth > 0
    [rt random 360 forward 1]
    [stop]

  ]
end


to spend
  ask turtles [
    if pcolor = green [
      set wealth wealth - 1
      set income income + 1
    ]
   ]
end

欢迎使用 NetLogo。 stop 是一个有趣的命令,它在不同的地方做不同的事情。特别是,它不会停止模拟,除非在 go 过程中或直接从过程中调用它。如果它确实从你放置它的地方停止了模型,它会在第一只乌龟实现零财富时停止,我假设你希望模型仅在所有乌龟的财富都为零时停止。我建议按如下方式修改模型:

to go
  if not any? turtles with [wealth > 0] [stop]
  move-turtles
  spend
  tick
end

to move-turtles
  ask turtles [
    if wealth > 0
    [rt random 360 forward 1]
  ]
end
    
to spend
  ask turtles with [wealth > 0] [
    if pcolor = green [
      set wealth wealth - 1
      set income income + 1
    ]
  ]
end

go 过程现在检查每个报价结束时的停止条件。我还在 spend 中添加了一行,以防止绿色斑块上的海龟的财富为负,尽管负财富可能对您有一些意义。如果是这样,你可以把那条线去掉。