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

Jump to any unoccupied location

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:
Begin description:
Jump to a random unoccupied location.
End description

Jump to unoccupied patch

Begin NetLogo code:
let unoccupied-patch one-of patches with [not any? objects-here with [not hidden?]]
 if is-patch? unoccupied-patch
  [set my-x [pxcor] of unoccupied-patch
   set my-y [pycor] of unoccupied-patch]
End NetLogo code

How this works

This finds any patch without a visible object on it. If there is such a patch it is then used to set the values of my-x and my-y.

Related micro-behaviours

Jump to unoccupied location in region differs from this behaviour in that a rectangular region is specified where the patch must be found. 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 any unoccupied location was implemented by Ken Kahn on 1 December 2012.
BehaviourComposer: ignore everything after this.
Comments