Пример #1
0
        public void AnyDeadCellWithExactlyThreeLiveNeighboursBecomesALiveCellAsIfByReproduction()
        {
            var grid = new Grid(new Cell(0, 0), new Cell(1, 0), new Cell(2, 0));

            grid = grid.CreateNextGeneration();

            Assert.True(grid.IsAlive(new Cell(1, 1)));
        }
Пример #2
0
        public void AnyLiveCellWithTwoLiveNeighboursLivesOnToTheNextGeneration()
        {
            var grid = new Grid(new Cell(1, 1), new Cell(0, 1), new Cell(2, 1));

            grid.CreateNextGeneration();

            Assert.True(grid.IsAlive(new Cell(1, 1)));
        }
Пример #3
0
        public void AnyLiveCellWithFewerThanTwoLiveNeighboursDiesAsIfCausedByUnderPopulation()
        {
            var grid = new Grid(new Cell(1, 1), new Cell(0, 1));

            grid = grid.CreateNextGeneration();

            Assert.False(grid.IsAlive(new Cell(1, 1)));
        }
Пример #4
0
        public void AnyLiveCellWithMoreThanThreeLiveNeighboursDiesAsIfByOvercrowding()
        {
            var grid = new Grid(new Cell(0, 0), new Cell(1, 0), new Cell(2, 0), new Cell(0, 1), new Cell(1, 1));

            grid = grid.CreateNextGeneration();

            Assert.False(grid.IsAlive(new Cell(1, 1)));
        }
Пример #5
0
 public void Update(GameTime gameTime)
 {
     updateTimer += gameTime.ElapsedGameTime;
     if (updateTimer.TotalMilliseconds > 1000f / Game1.UPS)
     {
         updateTimer = TimeSpan.Zero;
         _grid.CreateNextGeneration();
         _grid.TileCell.CopyGrid(lastGeneration, _grid.Scales);
         //for (int i = 0; i < _grid.Scales.X; i++){
         //    for (int j = 0; j < _grid.Scales.Y; j++){
         //        lastGeneration[i, j] = _grid.TileCell[i, j];
         //    }
         //}
     }
 }