de.tubs.cs.sc.casim
Interface CellularAutomaton

All Known Implementing Classes:
CALocal

public interface CellularAutomaton

defines an interface for a Cellular Automaton. This interface can be used in combination with this package and CACanvas to simulate and visualize a Cellular Automaton.

See Also:
de.tubs.cs.sc.cavis.CACanvas

Field Summary
static int HEXAGONAL
          the hexagonal geometry constant
static int SQUARE
          the square geometry constant
static int TRIANGLE
          the triangle geometry constant
 
Method Summary
 void backup()
          backups all cells of the CA to prepare for next time step using transition.
 void doBackStep()
          executes one time step back from configuration t to configuration t-1 The CA must be initialized and at least in time step 2 before calling doBackStep.
 void doNSteps(int n)
          executes n time steps from configuration t to configuration t+n The CA must be initialized before calling doNSteps.
 void doStep()
          executes one time step from configuration t to configuration t+1 The CA must be initialized before calling doStep.
 de.tubs.cs.sc.casim.BoundaryHandler getBoundaryHandler(int dim, boolean dir)
           
 int getDimension()
           
 int getGeneration()
           
 int getGeometry()
           
 de.tubs.cs.sc.casim.LatticeDefinition getLatticeDefinition()
           
 de.tubs.cs.sc.casim.State getOldState(int x)
           
 de.tubs.cs.sc.casim.State getOldState(int x, int y)
           
 de.tubs.cs.sc.casim.State getOldState(int x, int y, int z)
           
 java.lang.String getSizeString()
           
 de.tubs.cs.sc.casim.State getState(int x)
           
 de.tubs.cs.sc.casim.State getState(int x, int y)
           
 de.tubs.cs.sc.casim.State getState(int x, int y, int z)
           
 java.lang.Class getStateClass()
           
 de.tubs.cs.sc.casim.StateSetDefinition getStateSetDefinition()
           
 int getX()
           
 int getY()
           
 int getZ()
           
 void initialize()
          creates a new Lattice with the previously defined lattice parameters using setLatticeDefinition and the transition function defined by setStateClass or setStateSetDefinition.
 boolean isBlockCA()
           
 boolean isInitialized()
           
 void reset()
          resets the CA back to it's state after initialize.
 void setDescription(de.tubs.cs.sc.casim.CADescription desc)
          Every class that implements this interface can inherit his own CADescription, use this method to configure the respective class with his configuration.
 void setLatticeDefinition(de.tubs.cs.sc.casim.LatticeDefinition ld)
          setLatticeDefinition is used to define the lattice construction parameters.
 void setStateClass(java.lang.Class stateClass)
          Sets the state class for the CA.
 void setStateSetDefinition(de.tubs.cs.sc.casim.StateSetDefinition ssd)
          setStateSetDefinition is used to create a table driven CA.
 void transition()
          transitions all cells of the CA to execute a time step using transition of each Cell.
 

Field Detail

TRIANGLE

public static final int TRIANGLE
the triangle geometry constant

See Also:
getGeometry(), Constant Field Values

SQUARE

public static final int SQUARE
the square geometry constant

See Also:
getGeometry(), Constant Field Values

HEXAGONAL

public static final int HEXAGONAL
the hexagonal geometry constant

See Also:
getGeometry(), Constant Field Values
Method Detail

setStateClass

public void setStateClass(java.lang.Class stateClass)
Sets the state class for the CA. The state class must be derived from State, the class representing a cell's state. This class is used by Cell to instantiate a state for each cell of the CA. You first should set the state class and then set the properties of the lattice using setLatticeDefinition. If you don't want to derive your own state class you can use setStateSetDefinition instead.

See Also:
setLatticeDefinition(de.tubs.cs.sc.casim.LatticeDefinition), setStateSetDefinition(de.tubs.cs.sc.casim.StateSetDefinition), State

setLatticeDefinition

public void setLatticeDefinition(de.tubs.cs.sc.casim.LatticeDefinition ld)
setLatticeDefinition is used to define the lattice construction parameters. You can define the dimensions and the kind of the lattice. No Lattice will be created until calling initialize.

See Also:
initialize(), State.initialize(de.tubs.cs.sc.casim.Lattice, int), LatticeDefinition, Lattice

setDescription

public void setDescription(de.tubs.cs.sc.casim.CADescription desc)
Every class that implements this interface can inherit his own CADescription, use this method to configure the respective class with his configuration.

See Also:
CADescription

setStateSetDefinition

public void setStateSetDefinition(de.tubs.cs.sc.casim.StateSetDefinition ssd)
setStateSetDefinition is used to create a table driven CA. The class TableState of this package will be used to provide a transition function and a color table based on the StateSetDefinition.

See Also:
initialize(), setLatticeDefinition(de.tubs.cs.sc.casim.LatticeDefinition), setStateClass(java.lang.Class), StateSetDefinition

initialize

public void initialize()
                throws CAException
creates a new Lattice with the previously defined lattice parameters using setLatticeDefinition and the transition function defined by setStateClass or setStateSetDefinition. initialize creates the lattice all cells and initilizes the boundary handlers for the lattice. initialize calls then State.initialize once.

CAException
See Also:
Lattice, State.initialize(de.tubs.cs.sc.casim.Lattice, int), doStep()

isInitialized

public boolean isInitialized()
Returns:
true if the CellularAutomaton is already initialized, false otherwise

getDimension

public int getDimension()
Returns:
the dimension of the cellular automaton 1 .. for one dimensional CA's 2 .. for two dimensional CA's 3 .. for three dimensional CA's

getX

public int getX()
Returns:
the width of the cellular automaton

getY

public int getY()
Returns:
the height of the cellular automaton. one dimensional CA's will always have a height of 1.

getZ

public int getZ()
Returns:
the depth of the cellular automaton one and two dimensional CA's will always have a depth of 1.

getSizeString

public java.lang.String getSizeString()
Returns:
a string for the size of the cellular automaton. For a two dimensional CA a sample would be 10x10.

getGeometry

public int getGeometry()
Returns:
the geometry of the lattice of the CA.
  1. SQUARE for square cells
  2. TRIANGLE for triangle cells
  3. HEXAGONAL for hexagonal cells

getStateClass

public java.lang.Class getStateClass()
Returns:
the State class currently defined for the transition. A value of TableState indicates a table driven CA.
See Also:
State

getLatticeDefinition

public de.tubs.cs.sc.casim.LatticeDefinition getLatticeDefinition()
Returns:
the currently defined lattice parameters
See Also:
LatticeDefinition

getStateSetDefinition

public de.tubs.cs.sc.casim.StateSetDefinition getStateSetDefinition()
Returns:
the StateSetDefinition currently used, or null.
See Also:
StateSetDefinition

getBoundaryHandler

public de.tubs.cs.sc.casim.BoundaryHandler getBoundaryHandler(int dim,
                                                              boolean dir)
Returns:
the BoundaryHandler at the given dimension and direction.
See Also:
BoundaryHandler

getState

public de.tubs.cs.sc.casim.State getState(int x)
Returns:
the current state at the given position
See Also:
State

getState

public de.tubs.cs.sc.casim.State getState(int x,
                                          int y)
Returns:
the current state at the given position
See Also:
State

getState

public de.tubs.cs.sc.casim.State getState(int x,
                                          int y,
                                          int z)
Returns:
the current state at the given position
See Also:
State

getOldState

public de.tubs.cs.sc.casim.State getOldState(int x)
Returns:
the old state at the given position
See Also:
State

getOldState

public de.tubs.cs.sc.casim.State getOldState(int x,
                                             int y)
Returns:
the old state at the given position
See Also:
State

getOldState

public de.tubs.cs.sc.casim.State getOldState(int x,
                                             int y,
                                             int z)
Returns:
the old state at the given position
See Also:
State

reset

public void reset()
           throws CAException
resets the CA back to it's state after initialize. After calling reset the execution of the CA can be repeated calling doStep. No State class or LatticeDefinition will be changed.

CAException
See Also:
initialize()

doNSteps

public void doNSteps(int n)
executes n time steps from configuration t to configuration t+n The CA must be initialized before calling doNSteps. The execution stops earlier if the thread gets interrupted (Thread.interrupt() is called).

See Also:
initialize()

doStep

public void doStep()
executes one time step from configuration t to configuration t+1 The CA must be initialized before calling doStep. After every time step a CA can be visualised or analysed.

See Also:
initialize()

doBackStep

public void doBackStep()
executes one time step back from configuration t to configuration t-1 The CA must be initialized and at least in time step 2 before calling doBackStep. doBackStep is only available for Block CA's. Use isBlockCA to check this. After every time step a CA can be visualised or analysed.

See Also:
initialize(), doStep(), isBlockCA()

backup

public void backup()
backups all cells of the CA to prepare for next time step using transition. You must call backup each time step before transition. If you don't want to use backup and transition doStep will do both for you.

See Also:
transition(), doStep()

transition

public void transition()
                throws java.lang.IllegalStateException
transitions all cells of the CA to execute a time step using transition of each Cell. backup must be called first, even before the first time step

java.lang.IllegalStateException
See Also:
backup()

getGeneration

public int getGeneration()
Returns:
the generation counter. The generation counter counts the time steps executed by calling doStep.
See Also:
doStep()

isBlockCA

public boolean isBlockCA()
Returns:
true if this is a block CA, otherwise false