我想问一下,在X号滴答之后我是否想让女性孵化。 女性和男性在3月或4月交配并在1月或2月分娩。
在开始的时候,我制作了他们在1月和2月交配并生孩子的代码代码
to-report parents-here?
report any? turtles-here with [gender = "male"]
and
any? turtles-here with [gender = "female"]
end
to go
if ticks mod 12 <= 2 [
ask patches with [parents-here?] [
ask one-of turtles-here with [gender = "female"] [
hatch 1 [
set gender one-of ["male" "female"]
]
]
]
tick
端
但我怎么能问他们这里的父母是否现在这样,在这个女性可以孵化的确切数量之后(怀孕时间) 问题在于,当我使用gestaton 0然后+ 1时,它们仍然会在孵化后计算。
提前感谢您的帮助,并抱歉我的英语不好
答案 0 :(得分:0)
这可能不是您要求的,但您可以通过将海龟自己的变量用作妊娠倒计时来实现预期结果:
turtles-own [ gestation ]
to-report parents-here?
report any? turtles-here with [gender = "male"]
and
any? turtles-here with [gender = "female"]
end
to go
if ticks mod 12 <= 2 [
ask patches with [parents-here?] [
ask one-of turtles-here with [gender = "female"] [
set gestation 10
]
]
]
ask turtles with [gestation > 0] [
if [gestation = 1] [
hatch 1 [ set gender one-of ["male" "female"] ]
]
set gestation (gestation - 1)
]
tick
end