These pages are auto-generated from self-documenting comments embedded in class files.
For more information on breve and steve, refer to the breve homepage.

Abstract : Patch

Class description:

A patch is a non-physical object which is associated with a specific location in space. A patch can hold information about the state of the world in that location, such as the presence of a nutrient, for example. See the object PatchGrid for more information on setting up patches. Patches must be set up as part of a PatchGrid.

Because patches are not physical, they cannot move and they cannot collide with other objects. Though you can find the patch that an object is in, there is no collision callback when an object enters the patch. Patches can track the concentration of objects in their space. Currently this is limited to PatchChemical objects which are used to track information about abstract diffusable elements in the world. You can get the concentration, set the concentration, add and remove PatchChemcicals through the patch. See PatchGrid for adding PatchChemcials to the simulation and to iterate the diffusion. It is important to note that concentrations are stored in single precision floats currently to improve performance on hardware that supports SIMD processing.

The methods used to find neighboring patches depends on the type of simulation you're running. Though many of the "get-patch" methods described below behave the same as one another, they are named differently to be consistent with different types of simulations.

The neighbors are not fully initialized at the time that the init method is called. This is because the CLASS(PatchGrid) must create all of the patches before it can initialize the neighbors. Instead of accessing the neighbors in the init method, you should implement your own init-patch and place all initialization inside this method. The neighbors for the patch will be fully initialized by the time the init-patch method is called.

When using a 2D XY style simulation, use the following methods to get the four cardinal directions: get-patch-to-left, get-patch-to-right, get-patch-above and get-patch-below.

When using a 3D style simulation with and XZ ground plane (such that the vector (0, 1, 0) is pointing up, use the following methods to get the six cardinal directions: get-patch-to-north, get-patch-to-east, get-patch-to-south, get-patch-to-west, get-patch-above and get-patch-below.

These two groups of methods should suffice for most simulations, but if for some reason you use another orientation for your simulation which doesn't fit well with the vocabulary of these methods, you can use the following methods: get-patch-towards-plus-x, get-patch-towards-minus-x, get-patch-towards-plus-y, get-patch-towards-minus-y, get-patch-towards-plus-z and get-patch-towards-minus-z.

Methods:

  • decreaseConcentration
  • get3dMooreNeighborhood
  • get3dVonNeumannNeighborhood
  • getColor
  • getConcentration
  • getIndexVector
  • getLocation
  • getMooreNeighborhood
  • getPatchAbove
  • getPatchBelow
  • getPatchChemicals
  • getPatchToEast
  • getPatchToLeft
  • getPatchToLowerLeft
  • getPatchToLowerRight
  • getPatchToNorth
  • getPatchToRight
  • getPatchToSouth
  • getPatchToUpperLeft
  • getPatchToUpperRight
  • getPatchToWest
  • getPatchTowardsMinusX
  • getPatchTowardsMinusXMinusY
  • getPatchTowardsMinusXPlusY
  • getPatchTowardsMinusY
  • getPatchTowardsMinusZ
  • getPatchTowardsPlusX
  • getPatchTowardsPlusXMinusY
  • getPatchTowardsPlusXPlusY
  • getPatchTowardsPlusY
  • getPatchTowardsPlusZ
  • getTransparency
  • getVonNeumannNeighborhood
  • getXIndex
  • getYIndex
  • getZIndex
  • increaseConcentration
  • initNeighbors
  • initPatch
  • initWith
  • setColor
  • setConcentration
  • setPatchPointer
  • setTransparency
  • updateColors
    decreaseConcentration( self, theDiffusable, theValue )

    returns the concentration of a PatchChecmical in this patch.


    get3dMooreNeighborhood( self )

    Returns a list of the 3D Moore neighbors of this patch. The 3D Moore neighborhood consists of the 26 patches adjacent to this patch, including diagonally, in three dimensions.

    If you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.


    get3dVonNeumannNeighborhood( self )

    Returns a list of the 3D Von Neumann neighbors of this patch. The 3D Von Neumann neighborhood consists of the 6 patches directly adjacent to the faces of this patch, in three dimensions.

    If you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.


    getColor( self )

    Returns the color of the patch.


    getConcentration( self, theDiffusable )

    returns the concentration of a PatchChecmical in this patch.


    getIndexVector( self )

    Returns the x, y and z indices of this patch as a vector.


    getLocation( self )

    Returns the location of the patch.


    getMooreNeighborhood( self )

    Returns a list of the 2D Moore neighbors of this patch. The 2D Moore neighbors are the 8 patches adjacent to this patch, including diagonally, on the X/Y plane.

    If you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.


    getPatchAbove( self )

    Returns the patch towards (0, 1, 0).


    getPatchBelow( self )

    Returns the patch towards (0, -1, 0).


    getPatchChemicals( self )

    returns a list of all patch chemicals in the simulation


    getPatchToEast( self )

    Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (1, 0, 0).


    getPatchToLeft( self )

    Returns the patch towards (-1, 0, 0).


    getPatchToLowerLeft( self )

    Returns the patch towards (-1, -1, 0).


    getPatchToLowerRight( self )

    Returns the patch towards (1, -1, 0).


    getPatchToNorth( self )

    Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (0, 0, -1).


    getPatchToRight( self )

    Returns the patch towards (1, 0, 0).


    getPatchToSouth( self )

    Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (0, 0, 1).


    getPatchToUpperLeft( self )

    Returns the patch towards (-1, 1, 0).


    getPatchToUpperRight( self )

    Returns the patch towards (1, 1, 0).


    getPatchToWest( self )

    Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (-1, 0, 0).


    getPatchTowardsMinusX( self )

    Returns the patch towards (-1, 0, 0).


    getPatchTowardsMinusXMinusY( self )

    returns the patch towards (-1, -1, 0)


    getPatchTowardsMinusXPlusY( self )

    returns the patch towards (-1, 1, 0)


    getPatchTowardsMinusY( self )

    Returns the patch towards (0, -1, 0).


    getPatchTowardsMinusZ( self )

    Returns the patch towards (0, 0, -1).


    getPatchTowardsPlusX( self )

    Returns the patch towards (1, 0, 0).


    getPatchTowardsPlusXMinusY( self )

    returns the patch towards (1, -1, 0)


    getPatchTowardsPlusXPlusY( self )

    returns the patch towards (1, 1, 0)


    getPatchTowardsPlusY( self )

    Returns the patch towards (0, 1, 0).


    getPatchTowardsPlusZ( self )

    Returns the patch towards (0, 0, 1).


    getTransparency( self )

    Returns the transparency value of the patch.


    getVonNeumannNeighborhood( self )

    Returns a list of the 2D Von Neumann neighbors of this patch. The 2D Von Neumann neighbors are the 8 patches located above, below, to the left of and to the right of this patch on the X/Y plane.

    If you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.


    getXIndex( self )

    Returns the x index of the patch.


    getYIndex( self )

    Returns the y index of the patch.


    getZIndex( self )

    Returns the z index of the patch.


    increaseConcentration( self, theDiffusable, theValue )

    increases the amount of a PatchChecmical in this patch.


    initNeighbors( self )


    initPatch( self )

    This method does nothing in its default implementation. You can implement your own init-patch method in your patch class in order to perform initialization on the patch. This method is called after all the neighbor objects have been created--if you do initialization in the init method, the neighbors will not be initialized.


    initWith( self, gp, x, y, z )

    Used internally by the grid patch system when setting up the patches. Do not call this method. Just don't. I know it's tempting, but it's really better for all of us that you don't call it.


    setColor( self, newColor )

    Sets the color of the patch to newColor. Bear in mind that you'll also need to set the transparency of the patch if you want the patch to be displayed. See the method set-transparency for more information.


    setConcentration( self, theDiffusable, theValue )

    returns the concentration of a PatchChecmical in this patch.


    setPatchPointer( self, p )

    Used internally when setting up the patches. Do not call this method.


    setTransparency( self, alphaValue )

    Sets the transparency of the patch to alphaValue. alphaValue is a number between 0.0 (fully transparent) and 1.0 (fully opaque). The default value is 0.5, semi-transparent.


    updateColors( self )

    Used internally. Synchronizes the patch's color with recently dearchived values.