public void IsNotAliveNextGenerationTest()
        {
            LivingCell      livingCell      = new LivingCell();
            List <Location> livingNeighbors = new List <Location> {
                new Location(0, 0), new Location(0, 0), new Location(0, 0), new Location(0, 0)
            };

            Assert.IsFalse(livingCell.IsAliveNextGeneration(livingNeighbors));
        }
Exemple #2
0
        public void CellCoordinateNotEqualsInequivalentCoordinate()
        {
            Map testGrid = new Map();

            testGrid.AddCellAtCoordinate(5, 8);
            LivingCell testCell = testGrid.FindCellAtCoordinate(new Coordinate(5, 8));

            Assert.IsFalse(testCell.Coordinate.Equals(new Coordinate(5, 10)));
        }
Exemple #3
0
        public void NumberOfSurroundingLivingCellsIsCorrectInSameGrid()
        {
            Map testGrid = new Map();

            testGrid.AddCellAtCoordinate(5, 8);
            testGrid.AddCellAtCoordinate(5, 9);
            testGrid.AddCellAtCoordinate(6, 7);
            LivingCell testCell  = testGrid.FindCellAtCoordinate(new Coordinate(5, 8));
            LivingCell testCell2 = testGrid.FindCellAtCoordinate(new Coordinate(5, 9));

            Assert.AreEqual(2, testCell.Coordinate.NumberOfSurroundingLivingCells(testGrid));

            Assert.AreEqual(1, testCell2.Coordinate.NumberOfSurroundingLivingCells(testGrid));
        }
Exemple #4
0
        public void NumberOfSurroundingLivingCellsDoesNotTransferBetweenGrids()
        {
            Map testGrid  = new Map();
            Map testGrid2 = new Map();

            testGrid.AddCellAtCoordinate(5, 8);
            testGrid.AddCellAtCoordinate(5, 9);
            testGrid2.AddCellAtCoordinate(6, 7);
            LivingCell testCell  = testGrid.FindCellAtCoordinate(new Coordinate(5, 8));
            LivingCell testCell2 = testGrid.FindCellAtCoordinate(new Coordinate(5, 9));

            LivingCell testCell3 = testGrid2.FindCellAtCoordinate(new Coordinate(6, 7));

            Assert.AreEqual(1, testCell.Coordinate.NumberOfSurroundingLivingCells(testGrid));
            Assert.AreEqual(1, testCell2.Coordinate.NumberOfSurroundingLivingCells(testGrid));

            Assert.AreEqual(0, testCell3.Coordinate.NumberOfSurroundingLivingCells(testGrid2));
        }
 public FractalLifeGen(int height, int width) : base(height, width)
 {
     GridCells = new LivingCell[height, width];
     for (int ii = 0; ii < height; ++ii)
     {
         for (int jj = 0; jj < width; ++jj)
         {
             GridCells[ii, jj] = new LivingCell
             {
                 Name       = "Cell",
                 Background = new SolidColorBrush(Colors.White),
                 Row        = ii,
                 Col        = jj,
                 Enabled    = false,
                 Life       = 0
             };
         }
     }
     rules = new ToothpickRules(GridCells);
     Force(height / 2, width / 2);
 }
        public override void Update()
        {
            int count = active.Count;

            while (count > 0)
            {
                LivingCell cell = active.Dequeue() as LivingCell;
                if (cell.Life == lifespan)
                {
                    GetNextGen(cell).ForEach(c =>
                    {
                        c.Enabled = true;
                        active.Enqueue(c);
                    });
                }
                cell.Update(lifespan);
                if (cell.Enabled)
                {
                    active.Enqueue(cell);
                }
                --count;
            }
        }
        internal bool IsCellLiving(Coordinate coordinate)
        {
            LivingCell cell = gridMap.FindCellAtCoordinate(coordinate);

            return(cell != null);
        }
Exemple #8
0
 public void SetString_Sets_CellString()
 {
     LivingCell.SetString("o");
     Assert.Equal("o", livingCell.ToString());
 }
        public void LivingCellIsAliveTest()
        {
            LivingCell cell = new LivingCell();

            Assert.IsTrue(cell.IsAlive());
        }