1

我需要一些关于我的 NetLogo 模型的帮助。

目前我有乌龟(奶牛)在田野里漫游。它们以固定的速率将斑块颜色从绿色变为棕色(代表该斑块上的排便)。然而,就目前而言,这些补丁永远保持棕色,我想对其进行编码,以便在设定数量的滴答声(由我制作的滑块确定)后,补丁颜色变回绿色(代表粪便的退化)。

我目前的排便编码如下:

to cow-defecate
  ask untreated-cows
    [if random 100 < defecation-rate [set pcolor brown]]
end

非常感谢任何帮助-谢谢。

4

1 回答 1

1

我建议在 NetLogo 模型库的生物学部分查看 Wolf Sheep Predation 模型。它的代码正是这样做的。

代码的相关部分是:

patches-own [countdown]

to setup
  ...
  ask patches [
    set countdown random grass-regrowth-time
    set pcolor one-of [green brown]
  ]
  ..
end

to go
  ...
  ask sheep [ eat-grass ]
  ask patches [ grow-grass ]
  ...
end

to eat-grass  ;; sheep procedure
  if pcolor = green [
    set pcolor brown
  ]
end

to grow-grass  ;; patch procedure
  ;; countdown on brown patches: if reach 0, grow some grass
  if pcolor = brown [
    ifelse countdown <= 0
      [ set pcolor green
        set countdown grass-regrowth-time ]
      [ set countdown countdown - 1 ]
  ]
end

请注意,这grass-regrowth-time是一个滑块。

于 2013-11-07T13:06:06.090 回答