Example #1
0
        public GameOfLife()
        {
            IEnumerable <Cell> pattern = new RlePattern(Patterns.AlternateWichStrecher1);

            pattern = PatternUtils.OriginToCenter(pattern);
            _field  = new HashSet <Cell>(pattern);
            _runner = new LifeRunner(_field);
        }
Example #2
0
        public void TooLittleOrTooManyNeighbours_ShouldNotReproduce(
            Cell cell, IEnumerable <Cell> neighbours)
        {
            var cells  = new HashSet <Cell>(neighbours);
            var runner = new LifeRunner(cells);

            runner.RunCycle();

            Assert.DoesNotContain(cell, cells);
        }
Example #3
0
        public void EnoughNeighbours_ShouldReproduce(
            Cell cell, IEnumerable <Cell> neighbours)
        {
            var cells  = new HashSet <Cell>(neighbours);
            var runner = new LifeRunner(cells);

            runner.RunCycle();

            Assert.Contains(cell, cells);
        }
Example #4
0
        public void SingleCell_ShouldNotSurvive()
        {
            var cell  = new Cell();
            var cells = new HashSet <Cell> {
                cell
            };
            var runner = new LifeRunner(cells);

            runner.RunCycle();

            Assert.DoesNotContain(cell, cells);
        }