Example #1
0
 private void GameNew()
 {
     SetUiForGameState(GameStates.Idle);
     PregameCells = _grid.CreateEmptyGeneration();
     _gaea?.Clear();
     _gaea = null;
 }
Example #2
0
 private void RaiseGaeaOnDemand()
 {
     if (_gaea == null)
     {
         var generationZero = PregameCells.HasLiveCells ? PregameCells : _grid.CreateRandomGeneration();
         _gaea = new Gaea(_grid, new Rules(), UpdateGameVisualization, generationZero);
     }
     _gaea.DelayMilliseconds = SpeedSlider.Value;
 }
Example #3
0
        public void RunThrowsOnMissizedCells()
        {
            var gen = new Generation {
                { new RowCol(0, 0), false }
            };
            var gaea = new Gaea(new Grid(2, 2), new Rules(), (i, c) => { }, gen);

            Assert.Throws <ArgumentException>(() => gaea.Run());
        }
Example #4
0
        public void ThrowsOnInvalidDelay()
        {
            var tooSmall = Gaea.MinDelayMilliseconds - 1;
            var tooBig   = Gaea.MaxDelayMilliseconds + 1;
            var gaea     = new Gaea(new Grid(), new Rules());

            Assert.Throws <ArgumentOutOfRangeException>(() => gaea.DelayMilliseconds = tooSmall);
            Assert.Throws <ArgumentOutOfRangeException>(() => gaea.DelayMilliseconds = tooBig);
        }
Example #5
0
        public void DelayMillisecondsPropertyDefaultsAndSets()
        {
            var gaea = new Gaea(new Grid(), new Rules());

            Assert.AreEqual(Gaea.DefaultDelayMilliseconds, gaea.DelayMilliseconds);

            gaea.DelayMilliseconds = 100;
            Assert.AreEqual(100, gaea.DelayMilliseconds);
        }
Example #6
0
        public void CanBeCreated()
        {
            var grid  = new Grid();
            var rules = new Rules();

            var gaea = new Gaea(grid, rules);

            Assert.NotNull(gaea);
        }
Example #7
0
        public void RunThrowsOnNullCells()
        {
            var gaea = new Gaea(new Grid(), new Rules());

            Assert.Throws <ArgumentNullException>(() => gaea.Run());
        }