我正在寻找一种基于随机概率孵化海龟的程序:
根据这个概率,你是如何孵化海龟的?我应该使用什么程序?
发布于 2015-03-20 02:17:21
看起来A,B,C是品种吗?然后
to weighted-hatch ;; turtle-proc
let p random-float 100
if (p >= 60) [hatch-As 1 [init-A]]
if (if p >= 30 and p < 60) [hatch-Bs 1 [init-B]]
if (p < 30) [hatch-Cs 1 [init-C]]
end
to init-A
;;put any desired initializations here
end等。
您也可以使用rnd扩展;请参阅NetLogo, weighted random draw from a list: how to use rnd-extension?
发布于 2015-03-20 02:06:53
(抛出一个骰子伙伴!:)生成一个随机数,因为您有3个可能的选项,您可以使用类似random-float 1的方法--这在[0,1]中给出了一个数字。
然后,if 0>= number <=0.4 hatch A,else if 0.4< number <=0.7 hatch B等对C.
编码愉快!
https://stackoverflow.com/questions/29156262
复制相似问题