如何在规定的繁殖季节使海龟繁殖一次?

时间:2018-12-03 16:55:53

标签: netlogo

在我的模型中,我有雄性和雌性。它们可以每隔365天互相繁殖,以产生一个特定的tick。

当成年人繁殖后,如何使他们关闭繁殖能力,但在下一个繁殖季节恢复它们的能力。

ask females [
    if  age > 0 and age mod 365 = 0 [
  reproduce
    ]
.
.
.
to reproduce 
    if count mates > 0   [ ; the number of males in a defined radius 
    hatch fecundity [
    set mother myself
    set father one-of [mates] of mother
]

1 个答案:

答案 0 :(得分:3)

创建变量的一种方法,该变量计算自上次育种以来的天数。然后在每个刻度上递增该变量。一旦雌性成功繁殖,则将其重置。诸如此类(未经测试):

females-own [days-since-child]

to go
  ...
  ask females [ set days-since-child days-since-child + 1 ]
  ask females with [days-since-child >= 365] [ reproduce ]
  tick
end

to reproduce 
  if any? mates > 0   [ ; the number of males in a defined radius
    set days-since-child 0 
    hatch fecundity [
      set mother myself
      set father one-of [mates] of mother
    ]
  ]
end
相关问题