Beispiel #1
0
        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);
                }
            }
        }
Beispiel #2
0
        public int CountNeighboursOf(CellLocation cellLocation)
        {
            var numberOfNeighbouringCells = _surroundingCellLocations.GenerateSurroundingCellLocations(cellLocation);

            return(numberOfNeighbouringCells.Keys.Intersect(CellLocationsOfLivingCells.Keys).Count());
        }