public StandardLife(int inSize) { this._size = inSize; cells = new StandardCell[_size, _size]; for (int row = 0; row < _size; row++) { for (int column = 0; column < _size; column++) { cells[row, column] = new StandardCell(); } } }
public StandardLife(int inSize) { this._size = inSize; cells = new StandardCell[_size,_size]; for (int row =0; row < _size; row++) { for (int column = 0; column < _size; column++) { cells[row, column] = new StandardCell(); } } }
public override void Iterate() { StandardCell[,] newCells = new StandardCell[_size, _size]; for (int row = 0; row < _size; row++) { for (int column = 0; column < _size; column++) { int living = countLivingSurroundingCells(row, column); //standard conway rules: https://en.wikipedia.org/wiki/Conway's_Game_of_Life if (GetCell(row, column).IsAlive) { if (living == 2 || living == 3) { newCells[row, column] = new StandardCell(true); //alive } else { newCells[row, column] = new StandardCell(); //dead } } else { if (living == 3) { newCells[row, column] = new StandardCell(true); //alive } else { newCells[row, column] = new StandardCell(); //dead } } } } cells = newCells; }
public override void Iterate() { StandardCell[,] newCells = new StandardCell[_size,_size]; for (int row = 0; row < _size; row++) { for (int column = 0; column < _size; column++) { int living = countLivingSurroundingCells(row, column); //standard conway rules: https://en.wikipedia.org/wiki/Conway's_Game_of_Life if (GetCell(row, column).IsAlive) { if (living == 2 || living == 3) { newCells[row,column] = new StandardCell(true); //alive } else { newCells[row,column] = new StandardCell(); //dead } } else { if (living == 3) { newCells[row, column] = new StandardCell(true); //alive } else { newCells[row, column] = new StandardCell(); //dead } } } } cells = newCells; }