How to ask turtles to avoid a patch with specific color at patch-ahead 1 but turtles move forward by bigger number (not fd 1) in one step in NetLogo
<p>I am trying to ask turtles with any heading (random 360) to avoid the patches with red color. But, I observed that if a turtle is asked to move " fd 1 + random-float 2.0" then sometime turtles turns (set heading heading - 180) when there is a red patch ahead and sometimes(even most of the times) do not turn. Also when I ask the turtles to move " fd 1 " or " fd 0.1 + random-float 0.9 " the code works all fine. <em>Hopefully the reason behind is the number of patches I am asking the turtles to move in one step.</em> What will be the next patch for the move "fd 0.1 + random-float 0.9" and how could I make this working with patch-ahead 1. My code and the interface is  added. </p>

<p><a href="https://i.stack.imgur.com/5U7HL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5U7HL.png" alt="enter image description here"></a></p>

<pre><code>to setup
    clear-all
    ask patches [set pcolor green ]
    ask patches with [pycor = 3] [set pcolor red]

   create-turtles 40      
   [ 
      set color blue
      set xcor random-pxcor
      set ycor random-pycor
      set heading random 360
      set size 1
      set speed 1 + random-float 2.0
  ]
end

to go
  ask turtles [
    fd speed
    avoid-walls
  ]
end

to avoid-walls
   if [pcolor] of patch-ahead 1 = red [set heading heading - 180]
end
</code></pre>