de.tubs.cs.sc.casim
Class CALattice

java.lang.Object
  |
  +--de.tubs.cs.sc.casim.Lattice
        |
        +--de.tubs.cs.sc.casim.CALattice
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Lattice1D, Lattice2D, Lattice3D

public abstract class CALattice
extends Lattice

is the base class for all lattices for standard CA

See Also:
Serialized Form

Field Summary
protected  int[][] neighborhoodIndexes
           
 
Fields inherited from class de.tubs.cs.sc.casim.Lattice
boundaryHandler, lx, ly, lz
 
Constructor Summary
protected CALattice(java.lang.Class state, de.tubs.cs.sc.casim.LatticeDefinition ldef)
          Constructor calls base class constructor and initializes references to null
 
Method Summary
 void defineNeighborsArbitrary(int[][] indexes)
          defines an arbitrary neighborhood for the CA
protected abstract  de.tubs.cs.sc.casim.State getNeighborRelative(de.tubs.cs.sc.casim.Cell cell, int x, int y, int z)
          returns the relative neighbor of cell with given relative coordinates.
protected  de.tubs.cs.sc.casim.State[] getNeighbors(de.tubs.cs.sc.casim.Cell cell)
          returns the set of neighbors for cell.
protected abstract  de.tubs.cs.sc.casim.State[] getNeighborsArbitrary(de.tubs.cs.sc.casim.Cell cell)
          returns a previously defined arbitrary neighborhood.
protected abstract  de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell)
          returns the Moore neighborhood with radius 1.
protected abstract  de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell, int r)
          returns the Moore neighborhood with radius r.
protected abstract  de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell)
          returns the von Neumann neighborhood with radius 1.
protected abstract  de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell, int r)
          returns the von Neumann neighborhood with radius r.
protected abstract  int getNrOfNeighbors()
           
protected  void reversetransition()
          is only important for Block CA's and throws for CALattice always a RuntimeException
 
Methods inherited from class de.tubs.cs.sc.casim.Lattice
addBoundaryHandler, backup, beginBlock, callAnalyze, callInitialize, endBlock, finish, getBoundaryHandler, getDefinition, getDimension, getOldState, getState, getState, getState, getStateClass, getX, getY, getZ, reset, setNeighborhood, transition, waitForReadyForBackup, waitForReadyForTransition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

neighborhoodIndexes

protected int[][] neighborhoodIndexes
Constructor Detail

CALattice

protected CALattice(java.lang.Class state,
                    de.tubs.cs.sc.casim.LatticeDefinition ldef)
             throws CAException
Constructor calls base class constructor and initializes references to null

Method Detail

getNeighbors

protected de.tubs.cs.sc.casim.State[] getNeighbors(de.tubs.cs.sc.casim.Cell cell)
returns the set of neighbors for cell. Depending on the current LatticeDefinition the von Neumann or Moore neighborhood with the defined radius is calculated. getNeighbors is a package protected helper method for Cell. Cell is the only interface for the State subclass during transition. The subclass from State must not access it's coordinates. The coordinates are stored in Cell, Cell.getNeighbors is public and accessable for State, so Cell calculates it's neighborhood with Lattice.getNeighbors. Lattice.getNeighbors can access the coordinates of Cell, to detect all neighbors of Cell without searching the cell in the cell set. Cells coordinates and Lattice neighborhood are package protected, because State must not know about it's postion in the Lattice. One Cell class and the abstract Lattice can be used for all CAs. The implementation, especially the mapping from the lattice geometry and the data structures are implemented in subclasses of lattice.

Returns:
an array of States, all references must be casted to the State subclass.

getNrOfNeighbors

protected abstract int getNrOfNeighbors()
Returns:
the number of neighbors of every cell in the lattice

getNeighborsvonNeumann

protected abstract de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell)
returns the von Neumann neighborhood with radius 1.

Returns:
an array of States, all references must be casted to the State subclass.
See Also:
getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsMoore

protected abstract de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell)
returns the Moore neighborhood with radius 1.

Returns:
an array of States, all references must be casted to the State subclass.
See Also:
getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsvonNeumann

protected abstract de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell,
                                                                      int r)
returns the von Neumann neighborhood with radius r.

Returns:
an array of States, all references must be casted to the State subclass.
See Also:
getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsMoore

protected abstract de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell,
                                                                 int r)
returns the Moore neighborhood with radius r.

Returns:
an array of States, all references must be casted to the State subclass.
See Also:
getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsArbitrary

protected abstract de.tubs.cs.sc.casim.State[] getNeighborsArbitrary(de.tubs.cs.sc.casim.Cell cell)
returns a previously defined arbitrary neighborhood.

Returns:
an array of States, all references must be casted to the State subclass.
See Also:
getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborRelative

protected abstract de.tubs.cs.sc.casim.State getNeighborRelative(de.tubs.cs.sc.casim.Cell cell,
                                                                 int x,
                                                                 int y,
                                                                 int z)
returns the relative neighbor of cell with given relative coordinates.

Returns:
a State, the reference must be casted to the State subclass.
See Also:
getNeighbors(de.tubs.cs.sc.casim.Cell)

defineNeighborsArbitrary

public void defineNeighborsArbitrary(int[][] indexes)
defines an arbitrary neighborhood for the CA

Specified by:
defineNeighborsArbitrary in class Lattice

reversetransition

protected final void reversetransition()
is only important for Block CA's and throws for CALattice always a RuntimeException

Specified by:
reversetransition in class Lattice
See Also:
BlockState.reversetransition(de.tubs.cs.sc.casim.BlockState[])