SET-RANDOM-UNOCCUPIED-POSITION
Begin NetLogo code:let unoccupied-location random-location-found-to-be-unoccupied min-pxcor max-pxcor min-pycor max-pycor 1000000 set my-x first unoccupied-location set my-y second unoccupied-locationEnd NetLogo code
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.
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.