title: NetLogo: how to limit the blob size?
body: <p>I want to create a sort of feedbacks in process of harvesting my patches. In one timestep, I want to:</p>
  
  <ul>
  <li>select a patch harvest a patch </li>
  <li>decrease cost for neighboring patches
  up to certain level </li>
  <li>continue harvest (select) in neighbouring cells</li>
  <li>the maximum number of connected patches overpass certain level, move somewhere else</li>
  <li>add "protection" to cells neighboring the blob</li>
  </ul>
  
  <p>Simply, the harvest of patch always decreases cost of neighbouring patches, however my connected blob can't overpass specific size (i.e. number of patches). </p>
  
  <p>Here is what I've done until now - by combining different harvesting techniques (celect the firt patch, continue to harvest by blob or not..). However, I am sure there is simpliest way how to make it work?</p>
  
  <pre><code>globals [
    limit_harvest ]
  
  patches-own [
    forest?
    cost
  ]
  
  to setup
    clear-all
    setup-patches
    setup-turtles
    reset-ticks
  end
  
  to setup-patches
    ask patches [
      set pcolor green
      set forest? TRUE
      set cost 20
    ]
  end
  
  to setup-turtles
    crt 1
  end
  
  to go
    if any? patches with [forest? = TRUE] [
      harvest ]
    if ticks mod 20 = 0 [
      set limit_harvest 0 ]
  
    tick
  end
  
  to harvest
    ask turtles [
      ifelse by_blob? = FALSE [
       ; let min_cost min-one-of patches []
        move-to one-of patches with [
           forest? = TRUE]
        set pcolor red
        set forest? FALSE
        decrease_cost
      ]
      [ print "continuous"
        ifelse limit_harvest &lt;= 10 [   
           let min_cost min-one-of patches with [forest? = TRUE ] [cost]      
           move-to min_cost
           ;min-one-of patches with [forest? = TRUE] [distance myself]
           rt 360
           set pcolor red
           set forest? FALSE
           decrease_cost
           set limit_harvest limit_harvest + 1
       ]
        [ move-else ]
       ]
    ]
  end
  
  to move-else
    move-to one-of patches with [forest? = TRUE ]
    set pcolor yellow
    set forest? FALSE
    decrease_cost
    set limit_harvest limit_harvest + 1
    harvest2
  end
  
  to harvest2
    ifelse limit_harvest &lt;= 10 [   
           let min_cost min-one-of patches with [forest? = TRUE ] [cost]      
           move-to min_cost
           ;min-one-of patches with [forest? = TRUE] [distance myself]
           rt 360
           set pcolor red
           set forest? FALSE
           decrease_cost
           set limit_harvest limit_harvest + 1
       ]
        [ move-else ]
  end
  
  
  to decrease_cost
    ask patches in-radius 1 [ 
      set cost (cost  * 0.95 )]
     ask patches in-radius 2 [ 
      set cost (cost  * 0.85 )]
     ask patches in-radius 3 [ 
      set cost (cost  * 0.75 )]
     ask patches in-radius 4 [ 
      set cost (cost  * 0.65 )]
  end
  
  to view_cost
    ask patches [
      set pcolor scale-color red cost 10 0
    ]
  end 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Uw8FY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uw8FY.png" alt="enter image description here"></a></p>