Reference 〉 Class
baseAgent

Patch()

A patch is a spatially and numerically fixed agent primitive that forms the grid on which other agents move in a spatial model.

Patches inherit all methods from baseAgent, except those pertaining to motion, orientation, and reproduction; these will raise a RuntimeError. They can, for example, own stocks of goods and trade them. Patches will also have cardinal-direction properties returning the adjacent patch depending on the geometry:

  • Rectangular: patch.up, patch.down, patch.left, and patch.right
  • Polar: patch.clockwise, patch.counterclockwise, patch.inward, and patch.outward

These properties return a Patch object unless the patch abuts the map edge in that direction and wrapping is disabled.

Patches are registered automatically when a spatial model is initialized, and should not be instantiated manually.

Methods

Click a method name for more detailed documentation.

  • die( )

    Removes the patch from the board, and if spatial() had been initialized with offmap=False, prevents agents from moving to coordinates previously covered by the patch. Patches can be revived with basePatches.revive().

Object Properties

  • position tuple(int, int)

    For grid-based geometries, returns the coordinate position of the patch. For a geospatial model, returns the coordinate of the weighted center of the patch.

  • neighbors list[Patch]

    The patch's Moore or Von Neumann neighborhood, depending on the value of the corners parameter of model.spatial(). A patch is connected to its neighbors via a 'spatial' network.

    Initial value: []

  • agentsOn list[Agent]

    A list of agents whose current position is on the patch.

    Initial value: []

  • center tuple(num, num)

    Returns the center coordinate of the patch.

  • area num

    Returns the area of the patch. This will be 1 by definition in a rectangular geometry, and variable depending on distance from the center in a polar geometry.

  • vertices list[tuple(num, num)]

    A list of coordinates defining the corners of the patch.

Static Properties

  • fixed bool

    For patches, indicates that they cannot reproduce.

    Initial value: True

Notes and Examples

  1. 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.

History