Example #1
0
 public Cells()
 {
     cells = new Cell[SIZE];
     for (int i = 0; i < SIZE; i++)
     {
         cells[i] = new Cell();
         cells[i].setPotentialStates();
     }
 }
Example #2
0
 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();
     }
 }
Example #3
0
        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();

            }
        }
Example #4
0
 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;
 }