1

I used the code from How to create cluster patches that do not overlap between them to build patches as shown in the first figure below.

Here is the 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 ] ]

clear-all repeat 20 [ make-cluster ]

enter image description here

When I use this code in a large spatial extent (i.e. 1000 x 1000 patches with patch size = 1 pixel), green patches are like circles (see the second figure below). enter image description here

How can I have patches as shown in the first figure ?

Thank you very much for your help.

Community
  • 1
  • 1
Marine
  • 521
  • 1
  • 4
  • 23
  • Can you give some information about why you want to do this? I suspect there's a better general strategy. – Bryan Head Mar 02 '14 at 17:49
  • I would like to built a landscape in which green patches represent forest patches. I found that the first figure was interesting to capture heterogeneity in forest patches (i.e. different shapes of forest patches) instead of rectangular, circular or square patches. Thanks for your help. – Marine Mar 03 '14 at 01:13
  • Since you're okay with the blockiness of the first figure, why increase the number of patches so much? – Bryan Head Mar 03 '14 at 01:27
  • Thanks Bryan ! I increased the number of patches to have, for example, clusters of 0.6 km². Ideally, I would like to control area of forest clusters in my landscape. Clusters in the first figure should have the same area (number of green patches) as specified by the user. – Marine Mar 03 '14 at 17:01
  • Oh! I suppose this is for the same mode as: http://stackoverflow.com/questions/21919890/how-to-modify-spatial-extent-of-a-landscape. It seems like you have two pieces of land that exist on very different scales. Forest, etc, is huge. The paths, however, are small. You might consider representing the paths with links instead of patches. Then you can just increase the amount of forest that each patch represents. – Bryan Head Mar 03 '14 at 23:16
  • @Marine: If you like blockiness, why not try to characterize the blockiness you want mathematically, then attempt to write NetLogo code to express that math? Maybe you can solve it yourself. If not, show us your code and explain where you got stuck. You're asking vague questions and then expecting us to make your questions precise for you, *and* write the code for them. You should do more of the work yourself. – Seth Tisue Mar 05 '14 at 02:27
  • Here's a hint on the math part: if you want blocks of e.g. 5x5 patches, do your calculations with e.g. `floor (pxcor / 5)` and `floor (pycor / 5)` instead of `pxcor` and `pycor` directly. Something like that. – Seth Tisue Mar 05 '14 at 02:29

1 Answers1

1

If your goal is to simply have heterogeneous regions (rather than specifically blocky, symmetric things), you might play around with some of the answers here: Creating a random shape (blob) of a given area in NetLogo

Frank's solution and my first solution will probably run pretty slow on that large of a world. I just added a solution that should scale to a world of your size. I've put it here too for convenience:

to make-blob [ area x y ]
  let blob-maker nobody
  crt 1 [ set blob-maker self setxy x y ]
  let border patch-set [ patch-here ] of blob-maker
  repeat area [
    ask blob-maker [
      ask min-one-of border [ distance myself ] [
        set pcolor green
        set border (patch-set border neighbors4) with [ pcolor = black ]
      ]
      rt random 360
      fd .8
    ]
  ]
  ask blob-maker [ die ]
end

That said, if you like the blockiness, it's often the case that models with a large number of patches in a blocky formation can be reworked into models with a smaller number of patches that behave quite similarly. For example, one strategy is to scale down the size and movements of the turtles so that the world is still relatively large to them.

Community
  • 1
  • 1
Bryan Head
  • 12,360
  • 5
  • 32
  • 50
  • I can't run the script.. I have an Error message: 'make-blob expected 3 inputs' please, how can I run the script? – maycca Sep 23 '15 at 03:09
  • You need to pass three arguments to `make-blob`. For instance: `make-blob 20 3 4` will make a blob consisting of 20 patches that starts being made at `patch 3 4`. – Bryan Head Sep 23 '15 at 03:16
  • I must not understood it well because in my `to make-blob [20 3 4] let blob-maker nobody crt 1 [ set blob-maker self setxy 3 4 ] let border patch-set [ patch-here ] of blob-maker ...` it still doesn't work.. – maycca Sep 23 '15 at 03:27
  • So enter the code from post exactly as show in the code tab (starting with `make-blob [ area x y ]` and ending with `end`). Then, in the command center, enter `make-blob 20 3 4`. – Bryan Head Sep 23 '15 at 03:30