一段时间后为什么停机会停止?

时间:2016-04-16 06:38:01

标签: netlogo

早上好的每个人

编辑模型后,添加随机生成率:

to migrate
  if random-float 100 < random-spawn-rate
  [create-turtles 2 [rt random-float 360 fd 1]]
end

我遇到的问题是,在一种海龟(船只)消亡后,即使它们的随机孵化似乎也会消失? 我试过其他方法,但没有什么真正有用

请帮帮我 谢谢

完整代码:

breed [fish a-fish]
breed [boats boat]
boats-own [profit]

to setup
  clear-all
  ask patches [set pcolor blue]

  set-default-shape fish "fish"
  create-fish initial-number-fish
  [
    set color grey
    set size 1.0
    setxy random-xcor random-ycor
  ]

  set-default-shape boats "boat"
  create-boats initial-number-boats
  [
    set color black
    set size 1.5
    set profit random (1 * profit-per-fish)
    setxy random-xcor random-ycor
  ]
  reset-ticks
end

to go
  if not any? turtles [stop]
  ask fish
   [
    move
    fish-reproduce
   ]
   ask boats
   [
     move-boats
     catch-fish
     death
     reproduce-boats
     migrate
   ]
   tick
end

to move
  rt random 50
  lt random 50
  fd 1
end


to fish-reproduce
  if random-float 100 < fish-growth
  [hatch 1 [rt random-float 360 fd 1]]
end

to move-boats
   rt random 50
  lt random 50
  fd 1
  set profit profit - 0.1
end

to catch-fish
  let prey one-of fish-here
  if prey != nobody
  [ask prey [die]
    set profit profit + profit-per-fish]
end

to death
  if profit < 0 [die]
end

to reproduce-boats
  if profit > 1
  [
    set profit (profit / 2)
    hatch 1 [rt random-float 360 fd 1]]
end


to migrate
  if random-float 100 < random-spawn-rate
  [create-turtles 2 [rt random-float 360 fd 1]]
end

1 个答案:

答案 0 :(得分:1)

如果没有船只孵化新船,那么将不再建造船只。你的舱口取决于有多少艘船。

基本上,对于一艘船:

if profit > 1
  [
    set profit (profit / 2)
    hatch-boat 1 ...
   ]

每生成一艘船,你的利润减少了一半。除非你的利润增长或保持不变,否则你的船最终将会消亡,因为不会再孵化了。