src/main/java/com/brianscottrussell/gameoflife/GameGrid.java
/**
     * runs the rules on the grid to move to the next generation
     *  the result is an updated grid and an incremented generation
     */
runs the rules on the grid to move to the next generation
the result is an updated grid and an incremented generation
runs the rules on the grid to move to the next generation the result is an updated grid and an incremented generation
public void incrementGeneration() {
        CellStatus[][] nextGenerationGrid = new CellStatus[rowCount][colCount];
        for (int row = 0; row < this.rowCount; row++) {
            for(int col = 0; col < this.colCount; col++) {
                if(isCellInGrid(row, col)) {
                    if(matchesRuleOne(row, col)) {
                        nextGenerationGrid[row][col] = CellStatus.Dead;
                    }
                    else if(matchesRuleTwo(row, col)) {
                        nextGenerationGrid[row][col] = CellStatus.Dead;
                    }
                    else if(matchesRuleThree(row, col)) {
                        nextGenerationGrid[row][col] = CellStatus.Alive;
                    }
                    else if(matchesRuleFour(row, col)) {
                        nextGenerationGrid[row][col] = CellStatus.Alive;
                    }
                    else {
                        nextGenerationGrid[row][col] = this.grid[row][col];
                    }
                }
            }
        }
        this.grid = nextGenerationGrid;
        this.generation++;
    }
public void incrementGeneration ( ) { CellStatus [ ] [ ] nextGenerationGrid = new CellStatus [ rowCount ] [ colCount ] ; for ( int row = 0 ; row < this . rowCount ; row ++ ) { for ( int col = 0 ; col < this . colCount ; col ++ ) { if ( isCellInGrid ( row , col ) ) { if ( matchesRuleOne ( row , col ) ) { nextGenerationGrid [ row ] [ col ] = CellStatus . Dead ; } else if ( matchesRuleTwo ( row , col ) ) { nextGenerationGrid [ row ] [ col ] = CellStatus . Dead ; } else if ( matchesRuleThree ( row , col ) ) { nextGenerationGrid [ row ] [ col ] = CellStatus . Alive ; } else if ( matchesRuleFour ( row , col ) ) { nextGenerationGrid [ row ] [ col ] = CellStatus . Alive ; } else { nextGenerationGrid [ row ] [ col ] = this . grid [ row ] [ col ] ; } } } } this . grid = nextGenerationGrid ; this . generation ++ ; }
runs the rules on the grid to move to the next generation
  the result is an updated grid and an incremented generation
runs the rules on the grid to move to the next generation the result is an updated grid and an incremented generation
// TODO: can do better than O(n^2)? // enforce rules on this cell //   1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation. // kill cell //   2. Any live cell with more than three live neighbours dies, as if by overcrowding. // kill cell //   3. Any live cell with two or three live neighbours lives on to the next generation. // resurrect cell //   4. Any dead cell with exactly three live neighbours becomes a live cell. // resurrect cell // just copy cell