Netlogo 基于决策规则的浴缸模型萌芽
这里是netlogo的新手。我正在用细胞自动机模拟洪水模型。这只是一个简单的单细胞应该填充(改变颜色)或发芽,如果水>海拔 对于伪代码,我尝试这样做:Netlogo 基于决策规则的浴缸模型萌芽,netlogo,patch,cellular-automata,Netlogo,Patch,Cellular Automata,这里是netlogo的新手。我正在用细胞自动机模拟洪水模型。这只是一个简单的单细胞应该填充(改变颜色)或发芽,如果水>海拔 对于伪代码,我尝试这样做: to go ask patches with [pcolor != blue] ;remove ocean water_rise tick end to water_rise ; saturates cell if not any? turtles [ ask patch x-breach y-breac
to go
ask patches with [pcolor != blue] ;remove ocean
water_rise
tick
end
to water_rise ; saturates cell
if not any? turtles [
ask patch x-breach y-breach [ ;;; This will be the breach patch, will start to fill at first tick, a specific location in my map
set cell-storage elevation * fill-rate
]
]
ask patches [
;;; This has a patch check if any neighbors have sprouted.
;;; If any have, that patch starts to fill.
if any? neighbors4 with [ any? turtles-here ] [
set cell-storage elevation * fill-rate
let minv min [ cell-storage ] of patches
let maxv max [ cell-storage ] of patches
set pcolor scale-color green cell-storage 0 5 ;idea is to have a graduated color depending on fill stage
]
]
;;; Once all patches have had a chance this tick to fill,
;;; see if any are "full"
ask patches [
if cell-storage > elevation [
;; If the patch gets "full" and they have not already sprouted,
if not any? turtles-here [
sprout 1 [
set color yellow
set size 1
set shape "square"
]
]
]
]
结束
提前谢谢
顺便说一句,我正在研究DEM:高程值
我现在将填充率设置为0.3的滑块
-Nands我对它进行了一些研究,在我看来,你希望你的起始补丁填满,一旦它达到最大值,就开始涌入其他重复该过程的单元。我认为主要的问题是,在你的
水位上升
中,你要求所有海拔高于-9999的斑块首先调用起点
程序,然后如果它们有海拔低于单元存储量的邻域,也要让海龟发芽。似乎所有的斑块都满足这个条件,所以所有的斑块都会长出一只海龟
重新设计逻辑流程可能会更好,这样填充漏洞补丁就独立于其他补丁了。比如:
to water_rise ; saturates cell
if not any? turtles [
ask patch 0 0 [ ;;; This would be your breach patch, will start to fill at first tick
set cell-storage cell-storage + fill-rate
]
]
ask patches [
;;; This has a patch check if any neighbors have sprouted.
;;; If any have, that patch starts to fill.
if any? neighbors4 with [ any? turtles-here ] [
set cell-storage cell-storage + fill-rate
]
]
;;; Once all patches have had a chance this tick to fill,
;;; see if any are "full"
ask patches [
if cell-storage > 0 [
if cell-storage > 5 [
set cell-storage 5
;; If the patch gets "full" and they have not already sprouted, sprout 1
if not any? turtles-here [
sprout 1 [
set color yellow
set size 0.5
set shape "circle"
]
]
]
set pcolor cell-storage + 82
]
]
end
带有变量和设置的完整玩具模型
显然,您需要修改起始补丁(为了方便和简单,我使用了0)。此外,我还加入了
填充率
,以降低填充率,因为越来越多的补丁开始被填充。Nandoarz-您遇到了什么错误,或者您没有看到什么您希望看到的错误?嗨,luke。好像我没能设定好我的出发点,因为到处都在发芽。明白了。在这种情况下,你能提供更多的细节吗?照目前的情况,我们看不出您在哪里定义了“x违约”和“y违约”。这可能有助于包括您的设置过程。这只是我预加载的地图308和-36的随机坐标。单元存储也是一个虚拟值,仅用于测试此代码。谢谢Nands-我仍然不太确定你到底想做什么。你是否试图让细胞充满,然后“溢出”到相邻的细胞?至于为什么每个细胞都会发芽,那是因为在你的水上升过程中,你用查询所有的补丁,如果有的话?邻居4…
line.谢谢卢克!这有很大帮助,尤其是填充率变量。我仍然不明白为什么它没有从我想要的突破点开始。如果你介意的话,我可以给你整个剧本。谢谢我很乐意看一看。您的代码是否很长,或者您是否可以编辑上面的问题以及需要什么?NAND是否可以包含设置以显示变量定义?这将有助于了解为什么它不是从你的突破点开始的-在我上面链接的模型中,你可以只编辑补丁0 0
到你的突破点坐标,它将从那里开始-这不符合你的需要吗?此外,您的代码中存在一些错误-例如,我无法按原样运行它。例如,用[pcolor!=blue]
询问补丁(你让他们做什么?)。你好,卢克。很抱歉迟了答复。你的建议确实有帮助,我成功地运行了我的模型。再次非常感谢!