Untitled
public class Grid { private int[,] _cellAray; private const int Alive = 1; private const int Dead = 0; public Grid(int rows, int columns) { Random random = new Random(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { var randomValue = random.Next(0, 2); _cellAray[i, j] = randomValue == 1 ? Alive : Dead; } } } public void Step(){ var newCells = new int[_cellAray.GetLength(0), _cellAray.GetLength(1)]; for (int i = 0; i < _cellAray.GetLength(0); i++) { for (int j = 0; j < _cellAray.GetLength(1); j++) { } } } private int ApplyRules(int rowNr, int columnNr){ var numberOfNeighbours = CountAliveNeighbours(rowNr, columnNr); if(_cellAray[rowNr, columnNr] == Alive){ if(numberOfNeighbours == 2 || numberOfNeighbours == 3){ return Alive; } } else{ if(numberOfNeighbours == 3){ return Alive; } } return Dead; } }
Leave a Comment