private void CheckAgainstDeadEvolutionRules(GameWorld newWorld, CellLocation cellLocation) { var noCellsInLocation = _neighbourGenerator.GenerateSurroundingCellLocations(cellLocation); foreach (var cells in noCellsInLocation.Values) { var deadNeighours = CurrentWorld.CountNeighboursOf( cells); if (_deadEvolutionRules.CellStateBasedOnNumberOfNeighbours(deadNeighours)) { newWorld.AddCell(cells); } } }
public int CountNeighboursOf(CellLocation cellLocation) { var numberOfNeighbouringCells = _surroundingCellLocations.GenerateSurroundingCellLocations(cellLocation); return(numberOfNeighbouringCells.Keys.Intersect(CellLocationsOfLivingCells.Keys).Count()); }