我的经纪人生了太多孩子

时间:2018-07-19 11:57:29

标签: netlogo

我正在研究一个模型,该模型具有后代的有性繁殖,因此有两种媒介类型,雄性和雌性。我请特工在达到一定年龄后重现: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 

希望您能提供帮助!

1 个答案:

答案 0 :(得分:5)

ask females处理中不要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