Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create cluster patches that do not overlap between them

Tags:

netlogo

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

like image 548
Nell Avatar asked Dec 02 '13 19:12

Nell


1 Answers

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.

like image 86
Seth Tisue Avatar answered Oct 06 '22 01:10

Seth Tisue