Libraries‎ > ‎Library‎ > ‎Movement‎ > ‎

Jump to unoccupied location in region

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:
Begin description:
Jump to a random unoccupied location in the specified region.
End description

Jump to unoccupied
location in region

Begin NetLogo code:
substitute-text-area-for min-x min-pxcor
substitute-text-area-for max-x max-pxcor
substitute-text-area-for min-y min-pycor
substitute-text-area-for max-y max-pycor
let unoccupied-location random-unoccupied-location 
set my-x first unoccupied-location
set my-y second unoccupied-location
End NetLogo code


You can change the contents of the boxes to specify a region other than the whole environment.

How this works

This calls random-unoccupied-location which reports the location of a random unoccupied patch. The location is then used to set the values of xcor and ycor.

Related micro-behaviours

Jump to a random location will go to any location regardless of whether it is occupied.  Jump to location on a circle places agents in a circle. Place a set of agents in a rectangular grid places agents to fill a rectangle. Lay out a set of agents where the agents repel each other and the links between them act like springs attempts to find good locations for agents based upon their links with other agents. There are many movement behaviours in the main library.


Jump to unoccupied location was implemented by Ken Kahn.
BehaviourComposer: ignore everything after this.