public void ShouldGetNeighborsOfCell()
 {
     var sut = new World();
     var loc = new Location(1, 1);
     sut.PlaceCell(loc);
     sut.PlaceCell(new Location(1, 2));
     var result = sut.GetNeighborsOfLocation(loc);
     Assert.That(result, Is.EqualTo(1));
 }
Ejemplo n.º 2
0
 private void EvolveCells(World newWorld)
 {
     foreach (var item in CurrentWorld.OccupiedLocations)
     {
         var neighbors = CurrentWorld.GetNeighborsOfLocation(item);
         if (_livingLifeEngine.DetermineState(neighbors)) newWorld.PlaceCell(item);
         EvolveDeadCellsAroundLivingCell(newWorld, item);
     }
 }
Ejemplo n.º 3
0
        private void EvolveDeadCellsAroundLivingCell(World newWorld, Location livingLocation)
        {
            var unoccupiedLocations = _neighborGenerator.GenerateNeighbors(livingLocation, CurrentWorld.OccupiedLocations);

            foreach (var subitems in unoccupiedLocations)
            {
                var unOccupiedNeighbors = CurrentWorld.GetNeighborsOfLocation(subitems);
                if (_deadLifeEngine.DetermineState(unOccupiedNeighbors)) newWorld.PlaceCell(subitems);
            }
        }
 public void ShouldNotBeEmptyAfterCellIsPlacedInWorld()
 {
     var sut = new World();
     sut.PlaceCell(new Location());
     Assert.That(sut.IsEmpty, Is.EqualTo(false));
 }