Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

netlogo - To build patch clusters at large spatial scales

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...