How to set the target of the near turtle and follow it when world is not allowed to wrap (without going througt the walls)
<p>I have a problem with following the nearest candida (breed) by another turtle - neutrophil (breed). Candidas can't move and neutrophil looks for the nearest candida in the area, face to him and go forward. Everything is fine when world is allowed to wrap. Then neutrophils go througt the "walls" and chase candida. 
BUT the point is that world can't wrap.
So I created condidion with help another model, which bounce the neutrophil, when they reach one of the max coordinates. But now they keep bouncing from the walls and don't looking for another target.</p>

<p>I will be very thankful for help.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>to lookfor  ;;if meet candida in near area - chase, if not - continue looking for
  ifelse any? candidas [ chase ] [ move ]
end

to chase  ;;set the target on the nearest candida, face to them and move one step to him
  set nearest-candidas min-one-of candidas [ distance myself ]
  face nearest-candidas
  bounce fd 1
end

to move
  bounce
  fd 2
end

to bounce
   if abs pxcor = max-pxcor   [ set heading (- heading) ]  ;; bounce off top and bottom walls
   if abs pycor = max-pycor   [ set heading (180 - heading) ]
   if abs pzcor = max-pzcor   [ set heading (- heading) ]
   set nearest-candidas max-one-of candidas [ distance myself ]
end</code></pre>
</div>
</div>
</p>