daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. to find-clusters
  2.   loop [
  3.     ;; pick a random patch that isn't in a cluster yet
  4.     let seed one-of patches with [cluster = nobody
  5.     and pcolor = 8
  6.     ]
  7.     ;; if we can't find one, then we're done!
  8. if seed = nobody
  9. [
  10.   stop ]
  11. ;; otherwise, make the patch the "leader" of a new cluster
  12. ;; by assigning itself to its own cluster, then call
  13. ;; grow-cluster to find the rest of the cluster
  14. ask seed
  15. [ set cluster self
  16.   grow-cluster ]]
  17.   display
  18. end
  19.  
  20. to grow-cluster  ;; patch procedure
  21.   ask neighbors4 with [(cluster = nobody
  22.     and pcolor = 8
  23.     ) and
  24.     (pcolor = [pcolor] of myself)]
  25.   [ set cluster [cluster] of myself
  26.     grow-cluster ]
  27.    end
  28.    
  29. to calc-frequency
  30.   let freq map [[i] -> count patches with [cluster = i]] remove-
  31.    duplicates [cluster] of patches
  32.  
  33.   set-current-plot "Frequency distribution of urban patch size"
  34.   histogram freq
  35. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top