【发布时间】:2017-03-28 17:54:47
【问题描述】:
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 的滑块。
-南德
【问题讨论】:
-
Nandoarz - 您遇到了什么错误,或者您没有看到您希望看到的错误?
-
嗨,卢克。似乎我无法正确设置起点,因为到处都在发芽。
-
知道了。在这种情况下,您能否提供更多详细信息?照原样,我们看不到您在哪里定义了“x-breach”和“y-breach”。包含您的设置过程可能会有所帮助。
-
这只是我预加载地图 308 和 -36 的随机坐标。 cell-storage 也是一个虚拟值,仅用于测试此代码。谢谢!
-
Nands- 我还是不太确定你到底想做什么。您是否试图让细胞填满然后“溢出”到相邻的细胞中?至于为什么每个细胞都发芽,这是因为在您的
water_rise过程中,您正在使用if any? neighbors4 ...行查询 all 补丁。
标签: netlogo patch cellular-automata