我正在研究一个模型,该模型具有后代的有性繁殖,所以有两种媒介类型,雄性和雌性。我请特工在达到一定年龄后重现:400滴答声,并继续每400滴答声重复一次。
如果有男性,则女性只能生育一个孩子。该模型适用于前几代人,但随后激增。初始人口为一女一男,数字依次为:2、3、7、19、575。我不知道为什么它突然从19增加到575。
尽管有age = 0
,但看起来某些雌性后代会在出生后立即繁殖,即他们没有遵循以下命令:
ask females [
if age > 0 and age mod 400 = 0 [
reproduce
]
这是完整的模型:
turtles-own [age]
breed[males male]
breed[females female]
females-own [ mates max-mate-count mate-count availa-males mother father]
to setup
clear-all
crt 2 [
ifelse random 2 = 1 [set breed males] [set breed females]
]
ask females [set color grey
setxy random-xcor random-ycor
]
ask males [set color red
setxy random-xcor random-ycor
]
reset-ticks
end
to go
ask turtles [increment-age]
ask females [
if age > 0 and age mod 400 = 0 [
choose-mates
]
]
ask females [
if age > 0 and age mod 400 = 0 [
reproduce
]
]
tick
end
to increment-age
set age (1 + age)
end
to choose-mates
ask females [
set mates males in-radius 100 with [age >= 400]
]
end
to reproduce
ask females with [count mates > 0 ] [
hatch 1 [
set mother myself
set father one-of [mates] of mother
ifelse random 2 = 1 [set breed males
set color red
move-to one-of patches with [pcolor = black]
set age 0
]
[set breed females
set color grey
move-to one-of patches with [pcolor = black]
set mate-count 0
set age 0
]]]
end
希望能对您有所帮助!
最佳答案
不要在ask females
proc中使用reproduce
。见下文。我也提出了其他一些建议。
turtles-own [age]
breed[males male]
breed[females female]
females-own [ mates max-mate-count mate-count availa-males mother father]
to setup
clear-all
create-males 1 [init-male]
create-females 1 [init-female]
reset-ticks
end
to init
set age 0
move-to one-of patches with [pcolor = black]
ifelse (breed = males) [init-male][init-female]
end
to init-male
set color red
end
to init-female
set color gray
set mate-count 0
end
to-report fertile
report (age > 0 and age mod 400 = 0)
end
to go
ask turtles [increment-age]
let _fertile (females with [fertile])
ask _fertile [choose-mates]
ask _fertile [reproduce]
tick
end
to increment-age
set age (1 + age)
end
to choose-mates
;ask females [ ;DONT DO THIS!
set mates (males in-radius 100 with [age >= 400])
;]
end
to reproduce ;female proc
;ask females with [count mates > 0 ] [ ;DON'T DO THIS!!
if (count mates > 0) [ ;DO THIS INSTEAD
hatch 1 [
set mother myself
set father one-of [mates] of mother
set breed one-of (list males females)
init
]
]
end
关于netlogo - 我的经纪人生了太多 child ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51422111/