How to create cluster patches that do not overlap between them

烂漫一生 提交于 2019-11-26 23:36:43

问题


I would like to create habitat clusters (e.g. forest patches as in the subject of Marine : Adding patch clusters in a landscape) by controlling the size of clusters and the number of clusters ? For example, I used the code of "plant-migration" :

 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

How can I create cluster patches that do not overlap between them ? Thanks in advance


回答1:


Here's some sample code:

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

If I run it like this:

clear-all repeat 15 [ make-cluster ]

I get this:

Note that none of the clusters touch or overlap.



来源:https://stackoverflow.com/questions/20336364/how-to-create-cluster-patches-that-do-not-overlap-between-them

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!