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-pxcorsubstitute-text-area-for max-x max-pxcorsubstitute-text-area-for min-y min-pycorsubstitute-text-area-for max-y max-pycorlet unoccupied-location random-unoccupied-location                         (min-x)                        (max-x)                        (min-y)                        (max-y)set my-x first unoccupied-locationset my-y second unoccupied-location
End NetLogo code

Variants

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.

History

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