I jump to a random unoccupied location.

Begin micro-behaviour


Begin NetLogo code:
let unoccupied-location random-location-found-to-be-unoccupied min-pxcor max-pxcor
                                                               min-pycor max-pycor
set my-x first unoccupied-location
set my-y second unoccupied-location
End NetLogo code

Related Micro-behaviours

SET-RANDOM-POSITION sets my position to a random value even if occupied. WANDER-TO-AN-UNOCCUPIED-LOCATION moves to an unoccupied location within a region.

How this works

This calls random-location-found-to-be-unoccupied tries random coordinates until an unoccupied location is found or it gives up if 1000000 attempts fail to find an unoccupied spot. The location is then used to set the values of my-x and my-y.


This was implemented by Ken Kahn.