请为我的NetLogo模型提供一些帮助。
目前我有海龟(奶牛)在田野里漫游。在设定的速率下,它们将补丁颜色从绿色变为棕色(表示该补丁上的排便)。然而,就目前而言,那些贴片永远保持棕色,我想对其进行编码,以便在经过一定数量的刻度(由我制作的滑块确定)后,贴片颜色变回绿色(表示粪便的退化)。
我目前的排便编码如下:
to cow-defecate
ask untreated-cows
[if random 100 < defecation-rate [set pcolor brown]]
end
非常感谢任何帮助 - 谢谢。
答案 0 :(得分:1)
我建议在NetLogo模型库的Biology部分查看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
是一个滑块。