如何创建不重叠的群集修补程序

时间:2013-12-02 19:34:42

标签: netlogo

我想通过控制群集的大小和群集的数量来创建栖息地群集(例如,像Marine的主题中的森林斑块:Adding patch clusters in a landscape)?例如,我使用了“植物迁移”代码:

 to create-forests
 ask n-of forest-number patches
[
 set pcolor green 
]
ask patches with [pcolor = green]
[
 let a self
 let b max list 1 round(random-normal mean-forest-area (mean-forest-area * coef-forest-area))
 ask patches with [distance a <= b]
 [ 
   set pcolor green ]
 ]
end

如何创建不重叠的群集补丁? 提前致谢

1 个答案:

答案 0 :(得分:2)

以下是一些示例代码:

to make-cluster
  loop [
    let cluster [patches in-radius (2 + random-float 2)] of one-of patches
    if all? (patch-set [neighbors] of cluster) [pcolor = black] [
       ask cluster [ set pcolor green ]
       stop
    ]
  ]
end

如果我这样运行:

clear-all repeat 15 [ make-cluster ]

我明白了:

enter image description here

请注意,没有任何群集触及或重叠。