使用决策规则的浴缸模型发芽

bathtub model sprout using decision rules

这里是 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-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 re:高程值。

我现在将填充率设置为 0.3 的滑块。

-Nands

我试了一下这个,在我看来你想让你的起始补丁填满,一旦它达到最大值,就开始涌入重复这个过程的其他单元格。我认为主要问题是在你的 water-rise 中,你要求所有海拔大于 -9999 的补丁首先调用 starting-point 程序,然后如果它们有 any 个海拔低于单元格存储的邻居。似乎所有的补丁都满足那个条件,所以所有的补丁都会长出一只乌龟。

重新设计你的逻辑流程可能会更好,这样填充你的漏洞补丁就可以独立于其他补丁。类似于:

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

带有变量和设置的完整玩具模型here

显然,您需要修改起始补丁(为了方便和简单,我使用了 0 0)。此外,随着越来越多的补丁开始被填满,我将 fill-rate 作为一种减缓填充速度的方法。