NetLogo:杀死代理集的其余部分

NetLogo: kill rest of agentset

to change-vgags
  ifelse (((-0.007333 * x * x) + (0.07333 * x) + 1) = 1)
  [stop]
  [ifelse (((-0.007333 * x * x) + (0.07333 * x) + 1) > 1) 
  [ask n-of (((((-0.007333 * x * x) + (0.07333 * x) + (1)) / 48) - (1 / 48)) * 590) gags with [pcolor = red - 2] [ hatch 1 ]]
  [ask n-of (((1 / 48) - (((-0.007333 * x * x) + (0.07333 * x) + 1) / 48)) * 590) gags with [pcolor = red - 2] [die]]]

上面的代码是我现有的功能代码。由于堵嘴减少,他们将遵循最后一个告诉他们死亡的方程式。然而,我达到了它想要 15 个笑话死的地步,但我在特工集中只剩下 10 个。所以我试图在之后直接添加一行新代码,但它仍然给我同样的问题,很明显,这是不对的。我写的代码行写在下面。

  if (((1 / 48) - (((-0.007333 * x * x) + (0.07333 * x) + 1) / 48)) * 590) > count gags with [pcolor = red - 2] [ask gags with [pcolor = red - 2] [die]]
end

如果有人对如何解决这个问题有任何建议,我将不胜感激!提前致谢!

替换:

ask n-of ... gags with [pcolor = red - 2] [ die ]

与:

let quota ...
let targets gags with [pcolor = red - 2]
ask n-of min (list quota count targets) targets [ die ]

或者如果这看起来有点难以阅读,您可以随时:

let quota ...
let targets gags with [pcolor = red - 2]
if quota > count targets
  [ set quota count targets ]
ask n-of quota targets [ die ]