NetLogo:杀死其余的代理集

标签 netlogo kill 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 ]

关于NetLogo:杀死其余的代理集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31662480/

相关文章:

netlogo - 如何让一组斑 block 中的一只乌龟发芽

NetLogo 检查 turtle 是否在同一坐标上

Python - 无法终止进程

loops - Netlogo:如何迭代代理集并设置可变速度

list - 如何映射代理集?

netlogo - 我怎样才能加快我的最低成本路径模型的模拟速度

netlogo - 打印代理集中的元素

shell - 防止 POSIX xargs 尝试运行空命令

mysql - 安全地杀死一个删除大号。 mysql中的记录

netlogo - 如何从代理集中挑选随机代理来创建新的代理集?