public Cells() { cells = new Cell[SIZE]; for (int i = 0; i < SIZE; i++) { cells[i] = new Cell(); cells[i].setPotentialStates(); } }
public void setCells(Cell[] previousCells) { this.previousCells = previousCells; for (int i = 0; i < SIZE; i++) { State[] neighbourStates = getNeighbourStates(i); cells[i].setState(getTargetedState(neighbourStates, previousCells[i])); cells[i].setPotentialStates(); } }
public Cells(Int32 seed) { cells = new Cell[SIZE]; Random r = new Random(seed); for (int i = 0; i < SIZE; i++) { cells[i] = new Cell(); int randomNumber = r.Next(0, Enum.GetNames(typeof(State)).Length); cells[i].setStateRandomly(randomNumber); cells[i].setPotentialStates(); } }
private State getTargetedState(State[] neighbourStates, Cell cell) { State targetedState, leftState, rightState; leftState = neighbourStates[0]; rightState = neighbourStates[3]; targetedState = cell.getCurrentState; if (cell.getNextState == leftState && cell.getNextState == rightState) { targetedState = cell.getPreviousState; } else if (cell.getNextState == leftState || cell.getNextState == rightState) { targetedState = cell.getNextState; } else if (cell.getCurrentState == leftState && cell.getCurrentState == rightState) { targetedState = cell.getNextState; } return targetedState; }