6

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

Community
  • 1
  • 1
Nell
  • 559
  • 4
  • 20

1 Answers1

2

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:

enter image description here

Note that none of the clusters touch or overlap.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
  • By using this code in a large spatial extent (e.g 1000 x 1000 patches), why do all green patches take a circular shape ? Thank you for your help. – Marine Feb 28 '14 at 00:04
  • Not sure what you mean. How could the world size make a difference? – Seth Tisue Feb 28 '14 at 03:14
  • I used patch size = 1 pixel. Maybe this size is too small to well perceive variability in patch shape. Even if I modify the parameter "2 + random-float 2" in the code, green patches look like circles. Is it possible to increase "cutting-out" patches in order to have different patch shapes that are visible at large spatial scale ? Thank you very much for your help – Marine Mar 01 '14 at 02:40
  • Hmm... still not understanding. Isn't circles exactly what you would expect `in-radius` to produce? Maybe ask a new question with images showing what you're getting and what you want it to look like instead? – Seth Tisue Mar 01 '14 at 03:47
  • Is it possible to have green patch clusters as shown in the figure with the same area (i.e. same patch number in cluster) ? Thank you very much for your help. – Marine Mar 04 '14 at 03:56
  • Instead of `in-radius (2 + random-float 2)`, use a fixed radius. If you want the same area but different shapes, see http://stackoverflow.com/q/20997901/86485 – Seth Tisue Mar 04 '14 at 14:24
  • Thanks Seth ! In fact, I prefer to have symmetrical clusters with different shapes as shown in the figure. If, for example, I want to have clusters of 0.6 km² (i.e. 6000 patches in the cluster), is it possible to build symmetrical clusters of 6000 patches with different shapes ? Thank you very much for your help. – Marine Mar 04 '14 at 22:37
  • Seems like a new question. – Seth Tisue Mar 05 '14 at 02:19