如何给每个滴答随机数量的海龟变化二元变量(1或0),而在该变量中,任何时候不超过5%的现有总体的值为0?
换句话说,我希望具有可变值0的海龟的总量在每个蜱的海龟总量的0%或5%之间。
我怎样才能做到这一点?
我的代码是:
to setup
create-turtles 100
set var random 1 (only 5 % max shall have a 0 at start)
end
to start
change
end
to change
let %draw (random 1)
if (%draw < 0) … ; than I do not how to continue
end
n-of
原语选择指定数量的代理。你想要一些数字,所以你还需要随机生成数字。像这样的东西:
to setup
create-turtles 100 [ set var 1 ] ; give them all value 1
ask n-of random 6 turtles [ set var 0 ] ; randomly selects 0 to 5 turtles, assigns value 0
end