title: Netlogo, creating obstacle avoidance algorithm
body: <p>I am simulating pedestrian motion in NetLogo, and am having trouble creating an obstacle avoidance algorithm from scratch. There are algorithms online but they are not suited for moving obstacles (other pedestrians). In addition, my agents are moving from their spawnpoint (point A) to their goal (point B).</p>
  
  <p>This is my NetLogo algorithm:</p>
  
  <pre><code>globals [ wall walkway center dest ]
  turtles-own [ gender goal velocity spawnpoint mid turn ]
  
  to setup
    clear-all
    ask patches[
  set wall patches with [
    (pxcor &gt; 3 and pycor &gt; 3) or 
    (pxcor &lt; -3 and pycor &gt; 3) or
    (pxcor &lt; -3 and pycor &lt; -3) or
    (pxcor &gt; 3 and pycor &lt; -3)
    ]
  set walkway patches with [
    (pxcor &gt; -4 and pxcor &lt; 4) or
    (pycor &gt; -4 and pycor &lt; 4) 
  ]
  
  set center patch 0 0
    ]
  
    ask patches [
  set pcolor black
    ]
  
    ask walkway [
  set pcolor 9
    ]
  
    crt population [
  set velocity 0.1
  set mid 0
  
  set gender random 2
  if gender = 0 [set color red]
  if gender = 1 [set color blue]
  
  set spawnpoint random 4
  if spawnpoint = 0 [ move-to one-of walkway with [not any? turtles-here and (pxcor &lt; -11)]]
  if spawnpoint = 1 [ move-to one-of walkway with [not any? turtles-here and (pycor &gt; 11)]]
  if spawnpoint = 2 [ move-to one-of walkway with [not any? turtles-here and (pxcor &gt; 11)]]
  if spawnpoint = 3 [ move-to one-of walkway with [not any? turtles-here and (pycor &lt; -11)]]
  
  set goal random 4
  while [ goal = spawnpoint ] [ set goal random 4 ]
  if spawnpoint != 0 and goal = 0 [set goal patch -16 0]
  if spawnpoint != 1 and goal = 1 [set goal patch 0 16]
  if spawnpoint != 2 and goal = 2 [set goal patch 16 0]
  if spawnpoint != 3 and goal = 3 [set goal patch 0 -16]
    ]
  
    reset-ticks
  
  end
  to decelerate
    ifelse velocity &gt; 0.01
    [ set velocity velocity - 0.01 ]
    [ rt 5 ]
  end
  
  to accelerate
     if velocity &lt; 0.1
     [ set velocity velocity + 0.01 ]
  end
  
  to go 
  
    ask turtles [
     ifelse patch-here != goal[
       set turn random 2
       if distance center &lt; 3 [ set mid 1]
       if mid = 0 [ set dest center ]
       if mid = 1 [ set dest goal ]
       face dest
       ifelse any? other turtles-on patches in-cone 1.5 60
         [ if any? other turtles-on patches in-cone 1.5 60
           [ bk velocity
             rt 90 ]  ]
         [ accelerate
           face dest
           fd velocity ]
    ]
    [ die ]
  
    ]
  end
  </code></pre>
  
  <p>The simulated environment of this simulation is an intersection:</p>
  
  <p><a href="http://imgur.com/nQzhA7g,R5ZYJrp#0" rel="nofollow">http://imgur.com/nQzhA7g,R5ZYJrp#0</a></p>
  
  <p>(sorry, I need 10 rep to post images :( )</p>
  
  <p>Image 1 shows the state of the environment after setup. Image 2 shows what happens after the agents move to their goal (goal != their spawnpoint). The agents facing the different directions shows the agents which made its way past the clutter of agents in the center and are now on the way to their goal. The agents in the center, however, are stuck there because of my algorithm. The simulation is more problematic when there are more number of agents, which means they will just clutter in the center of the environment and just stutter when moving.</p>
  
  <p>I based my algorithm on <a href="http://files.bookboon.com/ai/Vision-Cone-Example-2.html" rel="nofollow">http://files.bookboon.com/ai/Vision-Cone-Example-2.html</a> . Forgive my algorithm, I started programming in NetLogo a week ago and until now I still don't have the proper mindset in programming in it. I'm sure there's a better way to implement what I have in mind, but alas I am frustrated upon trying many implementations that came to my mind (but never got close to the real thing).</p>
  
  <p>P.S: This is my first post/question in StackOverflow! I hope my question (and my way of asking) isn't bad.</p>