private void UpdateCells() { for (var i = 0; i < grid.gridLength; i++) { for (var j = 0; j < grid.gridWidth; j++) { Cell currentCell = grid.QueryContents(i, j); if (currentCell.IsAliveNextCycle()) { currentCell.Live(); } else { currentCell.Die(); } } } }
static void Main(string[] args) { _cells = new Cell[_gridSize, _gridSize]; // Population for (int x = 0; x < _gridSize; x++) { for (int y = 0; y < _gridSize; y++) { bool active = _random.Next(1, 100) <= _birthChanceAtStart; Cell cell = new Cell(x, y, active, _cells); _cells[x, y] = cell; } } // Generations for (int g = 0; g < _maxGenerations; g++) { Paint(g); Thread.Sleep(1000 / _generationsPerSecond); for (int x = 0; x < _gridSize; x++) { for (int y = 0; y < _gridSize; y++) { Cell cell = _cells[x, y]; if (cell.IsDead()) { cell.Die(); } else { cell.Ressurect(); } } } } }
public void AnAliveCellCanDie() { livecell.Die(); Assert.IsFalse(livecell.isAlive()); }
static void Main(string[] args) { _cells = new Cell[_gridSize, _gridSize]; // Population for (int x = 0; x < _gridSize; x++) { for (int y = 0; y < _gridSize; y++) { bool active = _random.Next(1, 100) <= _birthChanceAtStart; Cell cell = new Cell(x, y, active, _cells); _cells[x, y] = cell; } } // Generations for (int g = 0; g < _maxGenerations; g++) { Paint(g); Thread.Sleep(1000 / _generationsPerSecond); for (int x = 0; x < _gridSize; x++) { for (int y = 0; y < _gridSize; y++) { Cell cell = _cells[x, y]; if (cell.IsDead()) cell.Die(); else cell.Ressurect(); } } } }