浴缸模型萌芽使用决策规则

时间:2017-03-28 17:54:47

标签: 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-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"
      ]
  ]

]

] 结束 提前谢谢!

BTW,我正在研究DEM re:高程值。

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

-Nands

1 个答案:

答案 0 :(得分:1)

我对此玩了一下,在我看来,你希望你的起始补丁能够填满,一旦达到最大值,就开始涌入重复这个过程的其他细胞。我认为主要的问题是,在你的water-rise中,你要求所有高度大于-9999的补丁首先调用starting-point程序,然后如果他们有,还要发芽一只乌龟具有高程的任何邻居都小于单元存储。似乎所有补丁都满足这个条件,因此所有补丁都会发芽一只乌龟。

重写逻辑流程可能会更好,因此填写违规补丁与其他补丁无关。类似的东西:

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作为减慢填充率的方法。