Reference 〉 Class

PatchesRect( tuple(int, int) dim, bool|tuple(bool,bool) wrap = True,  **kwargs )

A coordinate system class defining a rectangular two-dimensional grid, where each column has the same number of rows. It assigns up, down, left, and right properties to patches, and moveUp(), moveDown(), moveLeft(), and moveRight() methods to non-patch agents, and also defines distance and angle functions on a rectangular grid.

This class should not be initialized in user code; it is initialized automatically with model.spatial(geometry='rect').

Initialization Parameters

  • dim tuple(int, int), required

    The (x,y) dimensions of the grid.

  • wrap bool|tuple(bool,bool), optional

    Whether patches at the edges of the map should be connected to patches on the opposite edge. PatchesRect can support several geometries this way:

    • False: Rectangular (no wrapping).
    • True: Toroidal (wrapping on both axes).
    • (True, False) or (False, True): Cylindrical (wrapping on one axis).

    Default value: True

  • **kwargs optional

    Additional arguments passed from model.spatial().

    Default value: {}


Click a method name for more detailed documentation.

  • neighbors( patch, corners )

    Defines the spatial network among the patches. This function is called automatically during spatial setup and should not be called by user code.

  • place( patch )

    Organizes Patch objects internally. Takes a patch object when created by model.nUpdater(), places it in the appropriate list, and assigns its position property.

Object Properties

  • dim tuple(int, int)

    The (x,y) dimensions of the grid.

  • boundaries tuple(tuple(int,int), tuple(int,int))

    A tuple of tuples with the maximum and minimum coordinates that agents can take, given the grid dimensions. ((xmin, xmax), (ymin, ymax)).

  • wrap tuple(bool, bool)

    Whether each respective dimension wraps around beyond the limits of boundaries.

Static Properties

  • geometry str

    The name of the patch geometry, to be set by subclasses.

    Initial value: ''

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.