title: How to make people go towards a specific patch and avoid certain patches on the way to the destination?
body: <p>I am building an evacuation model for my university lecture hall. The problem I am facing is that the people always walk over the gray patch that is not supposed to be walked over even though I have included the procedure to avoid walls in the code. This is the current code for my evacuation model. Also is it possible for the turtles to stop moving when arrived at the exit which in this case is the green patch?</p>
  <pre><code>breed [people person]
  
  to setup
    clear-all
    reset-ticks
    setup-patches
    setup-people
  end
  
  to setup-people
    set-default-shape people &quot;person&quot;
    ask n-of n-people (patches with [pcolor = white]) [sprout-people 1]
    ask people [set color cyan]
  end
  
  to setup-patches
    draw-wall
    draw-exit
  
    ;change the color of the floor for better visibility
    ask patches[
    if pcolor = black [set pcolor white ]
    ]
  end
  
  to draw-wall
  
    ; Make 4 boundary walls
    ask patches with [ pycor &gt;= -25  and pycor &gt;= 25][ set pcolor gray ]
    ask patches with [ pycor &lt;= -25  and pycor &lt;= 25][ set pcolor gray ]
    ask patches with [ pxcor &gt;= -25  and pxcor &gt;= 25][ set pcolor gray ]
    ask patches with [ pxcor &lt;= -25  and pxcor &lt;= 25][ set pcolor gray ]
  
    ; make rows of walls inside that look like seats in a lecture hall
    ; left rows of chairs 
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 20][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 18][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 16][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 14][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 12][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 10][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 8][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 6][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 4][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 2][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = 0][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = -2][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = -4][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = -6][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = -8][set pcolor gray]
    ask patches with [pxcor &lt;= 21 and pxcor &gt;= 13 and pycor = -10][set pcolor gray]
  
    ; middle rows of chairs 
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 20][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 18][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 16][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 14][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 12][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 10][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 8][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 6][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 4][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 2][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = 0][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = -2][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = -4][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = -6][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = -8][set pcolor gray]
    ask patches with [pxcor &gt;= -9 and pxcor &lt;= 9 and pycor = -10][set pcolor gray]
  
    ; right rows of chairs
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 20][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 18][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 16][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 14][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 12][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 10][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 8][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 6][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 4][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 2][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = 0][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = -2][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = -4][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = -6][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = -8][set pcolor gray]
    ask patches with [pxcor &gt;= -21 and pxcor &lt;= -13 and pycor = -10][set pcolor gray]
  
  end
  
  to draw-exit
  
    ; Setting 4 exits assuming all UTAR lecture halls have 4 exits
    ; two at the top left and right and two at the bottom left and right
    ask patches with [pxcor &lt;= 23 and pxcor &gt;= 21 and pycor = 25][set pcolor green]
    ask patches with [pxcor &gt;= -23 and pxcor &lt;= -21 and pycor = 25][set pcolor green]
    ask patches with [pxcor &lt;= 23 and pxcor &gt;= 21 and pycor = -25][set pcolor green]
    ask patches with [pxcor &gt;= -23 and pxcor &lt;= -21 and pycor = -25][set pcolor green]
  
  end
  
  to go
    let hall patches with [pycor &lt;= 0 and pycor &gt;= -25 and pxcor &lt;= 0 and pxcor &gt;= -25 ]
    ask people[
      move-people
      avoid-walls
    ]
    tick
  end
  
  to move-people
    face min-one-of patches with [pcolor = green ] [distance myself ]
    fd 0.1 
  end
  
   to avoid-walls
    ifelse [pcolor] of patch-ahead 1 = gray 
    [lt random-float 360 ] ;; we see a gray patch ahead of us. We turn a random amount
    [fd 0.1] ;; otherwise, it is safe to move forward  
  end
  </code></pre>