Reference 〉 Hook

agentPosition(agentAgent, modelHelipad)

Determines agent position on the launch of a spatial model. If not specified, agents are randomly positioned. In a spatial model, this hook runs for every primitive except patches, which have a fixed position.

Required Parameters

  • agent Agent

    The agent object to be positioned.

  • model Helipad

    The model object

Expected Return Value tuple(num, num)

A list or tuple with the (x,y) coordinates of the agent's initial position.

Notes and Examples

  1. charwick

    May 26, 2023 at 6:05

    If the spatial model has been initialized with offmap=False, this hook must return a position on a live patch, or a ValueError will be raised. This can be avoided by checking, which returns None if there is no patch under a coordinate.

    def agentPosition(agent, model):
        position = [0, random.uniform(0,patches.dim[1])]
        while not*position):
            position[0] += 1
        return position
  2. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.