Ejemplo n.º 1
0
        public void BlinkersFirstGenerationShouldGiveADifferentPattern()
        {
            var pattern = new List <PairOfInt>()
            {
                PairOfInt.Create(2, 1),
                PairOfInt.Create(2, 2),
                PairOfInt.Create(2, 3),
            };

            var game = new ConwayGame <IEnumerable <PairOfInt>, PairOfInt>(pattern, PairOfInt.GetNeighbours);

            game.NextGeneration();
            Assert.That(!game.CurrentPattern.SequenceEqual(pattern));
        }
Ejemplo n.º 2
0
        public void BlockShouldNotChange()
        {
            var pattern = new List <PairOfInt>()
            {
                PairOfInt.Create(1, 1),
                PairOfInt.Create(1, 2),
                PairOfInt.Create(2, 1),
                PairOfInt.Create(2, 2),
            };

            var game = new ConwayGame <IEnumerable <PairOfInt>, PairOfInt>(pattern, PairOfInt.GetNeighbours);

            game.NextGeneration();
            Assert.That(game.CurrentPattern.SequenceEqual(pattern));
        }
Ejemplo n.º 3
0
        public void DiehardShouldNotDieAfter1Generation()
        {
            var pattern = new List <PairOfInt>()
            {
                PairOfInt.Create(1, 7),
                PairOfInt.Create(2, 1),
                PairOfInt.Create(2, 2),
                PairOfInt.Create(3, 2),
                PairOfInt.Create(3, 6),
                PairOfInt.Create(3, 7),
                PairOfInt.Create(3, 8),
            };

            var game = new ConwayGame <IEnumerable <PairOfInt>, PairOfInt>(pattern, PairOfInt.GetNeighbours);

            game.NextGeneration();
            Assert.That(game.CurrentPattern.Any());
        }
Ejemplo n.º 4
0
        public void ToadShouldHaveAPeriodOfTwo()
        {
            var pattern = new List <PairOfInt>()
            {
                PairOfInt.Create(2, 2),
                PairOfInt.Create(2, 3),
                PairOfInt.Create(2, 4),
                PairOfInt.Create(3, 1),
                PairOfInt.Create(3, 2),
                PairOfInt.Create(3, 3),
            };

            var game = new ConwayGame <IEnumerable <PairOfInt>, PairOfInt>(pattern, PairOfInt.GetNeighbours);

            game.NextGeneration();
            game.NextGeneration();
            Assert.That(game.CurrentPattern.SequenceEqual(pattern));
        }
Ejemplo n.º 5
0
        public void LargePattern(int size)
        {
            var pattern = new List <PairOfInt>();

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    if ((i + j) % 2 == 0)
                    {
                        pattern.Add(PairOfInt.Create(i, j));
                    }
                }
            }

            var game = new ConwayGame <IEnumerable <PairOfInt>, PairOfInt>(pattern, PairOfInt.GetNeighbours);

            game.NextGeneration();
            Assert.That(!pattern.SequenceEqual(game.CurrentPattern));
        }