在孵化更多海龟的同时限制种群数量

Limiting Population Size while Hatching Additional Turtles

我有一个控制人口的滑块,设置为最大值 100,这会在巢中创建 100 只海龟。然而,一个品种内的海龟数量与总种群无关,因此我得到的不是 100 只海龟,而是 100 + #breed1 + #breed2。此外,在模型制作过程中,我正在孵化品种 [followers] 和 [foragers] 的新海龟。每次孵化新品种成员时,如何让海龟死亡? 我知道这不是代码问题,但理想情况下,我希望新的觅食者成为巢中的海龟,而不仅仅是新海龟。

to setup
  clear-all
  set-default-shape turtles "bug"
  create-turtles population
  create-foragers 10
  [set color yellow]
end

to go  ;; forever button
  ask leaders
  [wiggle
    fd 1
    return-to-nest]
  ask followers
  [if any? leaders
    [uphill-chemical
      fd 3
      pickup-food]
    uphill-food
    fd 1
    if distancexy nest-x nest-y < 3 and color = violet 
    [hatch-foragers 1
      [set color yellow
       uphill-chemical]]
  tick
end

to return-to-nest  ;; turtle procedure
ifelse nest?
  [if count followers < 5
    [hatch-followers 1 [set color brown - 1]]
  facexy food-x food-y  ;; drop food and head out again
  move-to patch food-x food-y]
[else commands]
end
````````

维持种群数量最简单的方法就是让一只刚出生的海龟杀死一只随机选择的海龟。所以代替:

[ if count followers < 5
  [ hatch-followers 1
    [ set color brown - 1
    ]
  ]

你可以:

[ if count followers < 5
  [ hatch-followers 1
    [ set color brown - 1
      ask one-of turtles [die]
    ]
  ]