netlogo - 如何让海龟在规定的繁殖季节繁殖一次?
问题描述
在我的模型中,我有男性和女性。它们可以相互繁殖,每 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
]
解决方案
一种创建变量的方法,该变量计算自上次繁殖以来的天数。然后在每个刻度上增加该变量。然后在雌性成功繁殖后将其重置。类似的东西(未测试):
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
推荐阅读
- r - 在 R 中选择多个历史日期后,Rvest Web 抓取
- c++ - 将 [[no_unique_address]] 与空基类继承组合时得到意外结果
- go - 使用 GORM 将接口设置为具有许多实现的属性
- javascript - babel 如何理解何时导入本地路径以及何时从同名库中导入?
- angular - 根据输入值更改输出类型
- jq - 使用 JQ 将 JSON 对象转换为数组
- python - 如何从选定的 Tkinter 单选按钮获取文本标签?
- python - 为什么django-q定时任务会随机延迟?
- json - availableFrom 没有可用值
- javascript - Javascript 对所有集合项执行代码