org.drools.examples.conway
Class Cell

java.lang.Object
  extended by org.drools.examples.conway.Cell

public class Cell
extends java.lang.Object

A Cell represents a single cell within a CellGrid. A cell may be either live or dead.

See Also:
CellState, CellGrid
 

Constructor Summary
Cell()
           
 
Method Summary
 void addNeighbor(Cell neighbor)
          ads a new neighbor to this neighbor
 CellState getCellState()
           
 int getNumberOfLiveNeighbors()
           
 int getNumberOfNeighboringCells()
           
 void queueNextCellState(CellState nextLiveState)
          tell this cell to queue its next live state. this is the state that this cell will be in after the cell is transitioned (after the next iteration).
 void setCellState(CellState newState)
          Sets this cells state
 boolean transitionState()
          Transitions this cell to its next state of evolution
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cell

public Cell()
Method Detail

getNumberOfNeighboringCells

public int getNumberOfNeighboringCells()
Returns:
the number of neighbors that this cell has
See Also:
Cell.getNumberOfLiveNeighbors()

getNumberOfLiveNeighbors

public int getNumberOfLiveNeighbors()
Returns:
the number of live neighbors that this cell has
See Also:
Cell.getNumberOfNeighboringCells()

addNeighbor

public void addNeighbor(Cell neighbor)
ads a new neighbor to this neighbor

Parameters:
neighbor - new neighbor

queueNextCellState

public void queueNextCellState(CellState nextLiveState)
tell this cell to queue its next live state. this is the state that this cell will be in after the cell is transitioned (after the next iteration). This transition state is necessary because of the 2 phase process involved in evolution.

Parameters:
nextLiveState - this cell's next live state
See Also:
CellState, Cell.getCellState(), Cell.transitionState()

transitionState

public boolean transitionState()
Transitions this cell to its next state of evolution

Returns:
true if the state changed, otherwise false
See Also:
Cell.queueNextCellState(CellState)

getCellState

public CellState getCellState()
Returns:
this cell's current life state
See Also:
Cell.queueNextCellState(org.drools.examples.conway.CellState), CellState

setCellState

public void setCellState(CellState newState)
Sets this cells state

Parameters:
newState - new state for this cell
See Also:
CellState