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
如果有人对如何解决这个问题有任何建议,我将不胜感激!提前谢谢!
答案 0 :(得分:3)
替换:
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 ]