title: Netlogo cluster count size: stack overflow (recursion too deep)
body: <p>In a land use model, I want to count the size of green and red clusters as shown in this image:</p>
  
  <p><a href="https://i.stack.imgur.com/TSsgd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TSsgd.png" alt="enter image description here"></a></p>
  
  <p>The code used is very similar to that found in "Patch Clusters example" from Models Library, with the only difference is that it only counts red and green patches. But when I run it, Netlogo states "stack overflow (recursion too deep) error while observer running ASK called by procedure FIND-CLUSTERS". Here is the find-clusters procedure:</p>
  
  <pre><code>to find-clusters
    loop [
      ;; pick a random patch that isn't in a cluster yet
      let seed one-of patches with [cluster = nobody and pcolor = 64 or 
  pcolor = 14]
      ;; if we can't find one, then we're done!
      if seed = nobody
      [ show-clusters
        stop ]
      ;; otherwise, make the patch the "leader" of a new cluster
      ;; by assigning itself to its own cluster, then call
      ;; grow-cluster to find the rest of the cluster
      ask seed
      [ set cluster self
        grow-cluster ]
    ]
    display
  end
  </code></pre>
  
  <p>and the grow-cluster procedure:</p>
  
  <pre><code>to grow-cluster  ;; patch procedure
    ask neighbors4 with [(cluster = nobody) and
      (pcolor = [pcolor] of myself)]
    [ set cluster [cluster] of myself
      grow-cluster ]
  end
  </code></pre>
  
  <p>What does the message mean and how can I fix it? Thanks.</p>