首页 > 解决方案 > 如何让海龟在规定的繁殖季节繁殖一次?

问题描述

在我的模型中,我有男性和女性。它们可以相互繁殖,每 365 天以特定的刻度产生后代。

我怎样才能让成年人在繁殖后关闭繁殖能力,但在下一个繁殖季节恢复能力。

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
]

标签: netlogo

解决方案


一种创建变量的方法,该变量计算自上次繁殖以来的天数。然后在每个刻度上增加该变量。然后在雌性成功繁殖后将其重置。类似的东西(未测试):

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

推荐阅读