如何在NetLogo中将性别随机分配给海龟品种?

如何在NetLogo中将性别随机分配给海龟品种?,netlogo,Netlogo,在我的一门课上,我们需要对疾病传播进行建模,并且让海龟,无论是病的还是健康的,在雄性和雌性到达同一个区域时进行繁殖,这也是基于一个具有繁殖概率的滑块。我们应该在出生时随机分配性别,以便生殖正常。你知道怎么做吗? 这是我目前的代码: to setup clear-all ifelse netlogo-web? [set max-turtles 300] [set max-turtles 300] create-healthy-cows Population-Size [ set sha

在我的一门课上,我们需要对疾病传播进行建模,并且让海龟,无论是病的还是健康的,在雄性和雌性到达同一个区域时进行繁殖,这也是基于一个具有繁殖概率的滑块。我们应该在出生时随机分配性别,以便生殖正常。你知道怎么做吗? 这是我目前的代码:

to setup
  clear-all
  ifelse netlogo-web? [set max-turtles 300] [set max-turtles 300]
  create-healthy-cows Population-Size [ set shape "cow"
     set color lime
     set infected? false
     set disease? false
     ask n-of (random Population-Size) turtles [set gender-male? true]
     set size 3
     setxy random-xcor random-ycor
     set age random 200
     set label-color black ]
end
而且:

to check-reproduction
 ask turtles [if gender-male? = false [
    ask turtles [if any? turtles-here with [gender-male? = true]
      [reproduce-cows] ]]]
end


to reproduce-cows
  ask turtles [ if max-turtles < 300 [
  ask turtles [if age >= 50 [if (random-float 100 < Reproduction-Rate)
      [hatch 1
        [set color blue] ]]]]]
end
检查复制
询问海龟[性别是否为男性?=错误[
询问海龟[如果有的话?海龟与[性别男性?=正确]
[繁殖奶牛]]]
结束
繁殖母牛
询问海龟[如果最大海龟数<300[
询问海龟[如果年龄>=50[如果(随机浮动100<繁殖率)
[舱口1
[设置颜色为蓝色]]]]]]]]
结束
另外,我有
性别男性?
设置为
海龟自己的

看看你是否能想出一个解决方案。重要的是要了解你在做什么以及为什么,而不仅仅是问答案,尤其是在课堂作业中


我从未见过或听说过NetLogo,我花了不到5分钟的时间想出了一个解决方案,然后找到了第二个更好的解决方案。。特别是如果这是一项作业,你应该在谷歌上搜索和研究,而不是要求别人用勺子舀

也没有足够的代表对OP问题进行评论和/或将[How to create random binary/boolean variable in Netlogo]()标记为可能的重复