本文介绍了如何概率孵化海龟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试寻找一种基于随机概率孵化海龟的程序:

I'm trying to find a procedure to hatch a turtle based on random probability:

  • A的40%
  • B的30%
  • C的30%

如何根据这种可能性孵化一只乌龟?我应该使用什么程序?

How do you hatch a turtle depending on that probability? What procedure/s should I use?

推荐答案

看起来A,B和C是品种?然后

It looks like A, B, and C are breeds? Then

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,从清单:如何使用rnd-extension?

You could alternatively use the rnd extension; see NetLogo, weighted random draw from a list: how to use rnd-extension?

这篇关于如何概率孵化海龟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 20:12