예제 #1
0
        public Generation GetGeneration()
        {
            var generationSize = new GenerationSize(50, 30);
            var generation     = new Generation(generationSize);

            generation.CurrentGeneration[2, 4]   = true;
            generation.CurrentGeneration[2, 5]   = true;
            generation.CurrentGeneration[2, 6]   = true;
            generation.CurrentGeneration[7, 5]   = true;
            generation.CurrentGeneration[7, 6]   = true;
            generation.CurrentGeneration[7, 10]  = true;
            generation.CurrentGeneration[7, 11]  = true;
            generation.CurrentGeneration[7, 12]  = true;
            generation.CurrentGeneration[9, 4]   = true;
            generation.CurrentGeneration[9, 5]   = true;
            generation.CurrentGeneration[9, 6]   = true;
            generation.CurrentGeneration[9, 10]  = true;
            generation.CurrentGeneration[12, 9]  = true;
            generation.CurrentGeneration[12, 14] = true;
            generation.CurrentGeneration[14, 4]  = true;
            generation.CurrentGeneration[14, 5]  = true;
            generation.CurrentGeneration[14, 6]  = true;
            generation.CurrentGeneration[14, 10] = true;
            generation.CurrentGeneration[14, 11] = true;
            generation.CurrentGeneration[14, 12] = true;
            generation.CurrentGeneration[24, 10] = true;
            generation.CurrentGeneration[24, 1]  = true;
            generation.CurrentGeneration[24, 21] = true;
            generation.CurrentGeneration[24, 14] = true;
            generation.CurrentGeneration[24, 12] = true;

            return(generation);
        }
예제 #2
0
        public Generation GetGeneration()
        {
            var generationSize = new GenerationSize(17, 17);
            var generation     = new Generation(generationSize);

            generation.CurrentGeneration[2, 4]   = true;
            generation.CurrentGeneration[2, 5]   = true;
            generation.CurrentGeneration[2, 6]   = true;
            generation.CurrentGeneration[2, 10]  = true;
            generation.CurrentGeneration[2, 11]  = true;
            generation.CurrentGeneration[2, 12]  = true;
            generation.CurrentGeneration[4, 2]   = true;
            generation.CurrentGeneration[4, 7]   = true;
            generation.CurrentGeneration[4, 9]   = true;
            generation.CurrentGeneration[4, 14]  = true;
            generation.CurrentGeneration[5, 2]   = true;
            generation.CurrentGeneration[5, 7]   = true;
            generation.CurrentGeneration[5, 9]   = true;
            generation.CurrentGeneration[5, 14]  = true;
            generation.CurrentGeneration[6, 2]   = true;
            generation.CurrentGeneration[6, 7]   = true;
            generation.CurrentGeneration[6, 9]   = true;
            generation.CurrentGeneration[6, 14]  = true;
            generation.CurrentGeneration[7, 4]   = true;
            generation.CurrentGeneration[7, 5]   = true;
            generation.CurrentGeneration[7, 6]   = true;
            generation.CurrentGeneration[7, 10]  = true;
            generation.CurrentGeneration[7, 11]  = true;
            generation.CurrentGeneration[7, 12]  = true;
            generation.CurrentGeneration[9, 4]   = true;
            generation.CurrentGeneration[9, 5]   = true;
            generation.CurrentGeneration[9, 6]   = true;
            generation.CurrentGeneration[9, 10]  = true;
            generation.CurrentGeneration[9, 11]  = true;
            generation.CurrentGeneration[9, 12]  = true;
            generation.CurrentGeneration[10, 2]  = true;
            generation.CurrentGeneration[10, 7]  = true;
            generation.CurrentGeneration[10, 9]  = true;
            generation.CurrentGeneration[10, 14] = true;
            generation.CurrentGeneration[11, 2]  = true;
            generation.CurrentGeneration[11, 7]  = true;
            generation.CurrentGeneration[11, 9]  = true;
            generation.CurrentGeneration[11, 14] = true;
            generation.CurrentGeneration[12, 2]  = true;
            generation.CurrentGeneration[12, 7]  = true;
            generation.CurrentGeneration[12, 9]  = true;
            generation.CurrentGeneration[12, 14] = true;
            generation.CurrentGeneration[14, 4]  = true;
            generation.CurrentGeneration[14, 5]  = true;
            generation.CurrentGeneration[14, 6]  = true;
            generation.CurrentGeneration[14, 10] = true;
            generation.CurrentGeneration[14, 11] = true;
            generation.CurrentGeneration[14, 12] = true;

            return(generation);
        }
        public void Build_WithPatternBlinkerPeriod2WithNotSquareArray_HaveTheRightResult()
        {
            // Arrange
            var generationSize           = new GenerationSize(5, 6);
            var generationNumber         = 50;
            var expectedGenerationNumber = generationNumber + 1;
            var generation = new Generation(generationSize, generationNumber);

            generation.CurrentGeneration[2, 1] = true;
            generation.CurrentGeneration[2, 2] = true;
            generation.CurrentGeneration[2, 3] = true;
            var services = new NextGenerationService();

            // Act
            var newGeneration = services.Build(generation);

            //Assert
            Assert.Equal(expectedGenerationNumber, newGeneration.GenerationNumber);
            // First line
            Assert.False(newGeneration.CurrentGeneration[0, 0]);
            Assert.False(newGeneration.CurrentGeneration[0, 1]);
            Assert.False(newGeneration.CurrentGeneration[0, 2]);
            Assert.False(newGeneration.CurrentGeneration[0, 3]);
            Assert.False(newGeneration.CurrentGeneration[0, 4]);

            // Second Line
            Assert.False(newGeneration.CurrentGeneration[1, 0]);
            Assert.False(newGeneration.CurrentGeneration[1, 1]);
            Assert.True(newGeneration.CurrentGeneration[1, 2]);
            Assert.False(newGeneration.CurrentGeneration[1, 3]);
            Assert.False(newGeneration.CurrentGeneration[1, 4]);

            // Thrid Line
            Assert.False(newGeneration.CurrentGeneration[2, 0]);
            Assert.False(newGeneration.CurrentGeneration[2, 1]);
            Assert.True(newGeneration.CurrentGeneration[2, 2]);
            Assert.False(newGeneration.CurrentGeneration[2, 3]);
            Assert.False(newGeneration.CurrentGeneration[2, 4]);

            // Fourth Line
            Assert.False(newGeneration.CurrentGeneration[3, 0]);
            Assert.False(newGeneration.CurrentGeneration[3, 1]);
            Assert.True(newGeneration.CurrentGeneration[3, 2]);
            Assert.False(newGeneration.CurrentGeneration[3, 3]);
            Assert.False(newGeneration.CurrentGeneration[3, 4]);

            // Fifth Line
            Assert.False(newGeneration.CurrentGeneration[4, 0]);
            Assert.False(newGeneration.CurrentGeneration[4, 1]);
            Assert.False(newGeneration.CurrentGeneration[4, 2]);
            Assert.False(newGeneration.CurrentGeneration[4, 3]);
            Assert.False(newGeneration.CurrentGeneration[4, 4]);
        }
        public Generation GetGeneration()
        {
            var generationSize = new GenerationSize(6, 6);
            var generation     = new Generation(generationSize);

            generation.CurrentGeneration[1, 1] = true;
            generation.CurrentGeneration[2, 1] = true;
            generation.CurrentGeneration[1, 2] = true;
            generation.CurrentGeneration[4, 3] = true;
            generation.CurrentGeneration[3, 4] = true;
            generation.CurrentGeneration[4, 4] = true;

            return(generation);
        }
        public void Build_WhenAGenerationIsBuilt_TheGenerationNumber_IsIncremented()
        {
            // Arrange
            var generationSize           = new GenerationSize(100, 100);
            var generationNumber         = 50;
            var expectedGenerationNumber = generationNumber + 1;
            var generation = new Generation(generationSize, generationNumber);
            var services   = new NextGenerationService();

            // Act
            var newGeneration = services.Build(generation);

            //Assert
            Assert.Equal(expectedGenerationNumber, newGeneration.GenerationNumber);
        }
예제 #6
0
        public Generation GetGeneration()
        {
            var generationSize = new GenerationSize(40, 40);

            var generation = new Generation(generationSize);

            generation.CurrentGeneration[5, 26]  = true;
            generation.CurrentGeneration[6, 24]  = true;
            generation.CurrentGeneration[6, 26]  = true;
            generation.CurrentGeneration[7, 14]  = true;
            generation.CurrentGeneration[7, 15]  = true;
            generation.CurrentGeneration[7, 22]  = true;
            generation.CurrentGeneration[7, 23]  = true;
            generation.CurrentGeneration[7, 36]  = true;
            generation.CurrentGeneration[7, 37]  = true;
            generation.CurrentGeneration[8, 13]  = true;
            generation.CurrentGeneration[8, 17]  = true;
            generation.CurrentGeneration[8, 22]  = true;
            generation.CurrentGeneration[8, 23]  = true;
            generation.CurrentGeneration[8, 36]  = true;
            generation.CurrentGeneration[8, 37]  = true;
            generation.CurrentGeneration[9, 2]   = true;
            generation.CurrentGeneration[9, 3]   = true;
            generation.CurrentGeneration[9, 12]  = true;
            generation.CurrentGeneration[9, 18]  = true;
            generation.CurrentGeneration[9, 22]  = true;
            generation.CurrentGeneration[9, 23]  = true;
            generation.CurrentGeneration[10, 2]  = true;
            generation.CurrentGeneration[10, 3]  = true;
            generation.CurrentGeneration[10, 12] = true;
            generation.CurrentGeneration[10, 16] = true;
            generation.CurrentGeneration[10, 18] = true;
            generation.CurrentGeneration[10, 19] = true;
            generation.CurrentGeneration[10, 24] = true;
            generation.CurrentGeneration[10, 26] = true;
            generation.CurrentGeneration[11, 12] = true;
            generation.CurrentGeneration[11, 18] = true;
            generation.CurrentGeneration[11, 26] = true;
            generation.CurrentGeneration[12, 13] = true;
            generation.CurrentGeneration[12, 17] = true;
            generation.CurrentGeneration[13, 14] = true;
            generation.CurrentGeneration[13, 15] = true;

            return(generation);
        }
예제 #7
0
        public Generation GetGeneration()
        {
            var generationSize = new GenerationSize(11, 18);
            var generation     = new Generation(generationSize);

            generation.CurrentGeneration[4, 5]  = true;
            generation.CurrentGeneration[5, 5]  = true;
            generation.CurrentGeneration[6, 4]  = true;
            generation.CurrentGeneration[6, 6]  = true;
            generation.CurrentGeneration[7, 5]  = true;
            generation.CurrentGeneration[8, 5]  = true;
            generation.CurrentGeneration[9, 5]  = true;
            generation.CurrentGeneration[10, 5] = true;
            generation.CurrentGeneration[11, 4] = true;
            generation.CurrentGeneration[11, 6] = true;
            generation.CurrentGeneration[12, 5] = true;
            generation.CurrentGeneration[13, 5] = true;

            return(generation);
        }
        public void Build_WithPatternBeaconPeriod2_HaveTheRightResultAfterTwoGeneration()
        {
            // Arrange
            var generationSize            = new GenerationSize(6, 6);
            var generationNumber          = 50;
            var expectedGeneration1Number = generationNumber + 1;
            var expectedGeneration2Number = expectedGeneration1Number + 1;
            var generation = new Generation(generationSize, generationNumber);

            generation.CurrentGeneration[1, 1] = true;
            generation.CurrentGeneration[2, 1] = true;
            generation.CurrentGeneration[1, 2] = true;
            generation.CurrentGeneration[4, 3] = true;
            generation.CurrentGeneration[3, 4] = true;
            generation.CurrentGeneration[4, 4] = true;

            var services = new NextGenerationService();

            // Act
            var newGeneration1 = services.Build(generation);
            var newGeneration2 = services.Build(newGeneration1);

            //Assert

            // Generation 1
            Assert.Equal(expectedGeneration1Number, newGeneration1.GenerationNumber);

            Assert.False(newGeneration1.CurrentGeneration[0, 0]);
            Assert.False(newGeneration1.CurrentGeneration[1, 0]);
            Assert.False(newGeneration1.CurrentGeneration[2, 0]);
            Assert.False(newGeneration1.CurrentGeneration[3, 0]);
            Assert.False(newGeneration1.CurrentGeneration[4, 0]);
            Assert.False(newGeneration1.CurrentGeneration[5, 0]);

            Assert.False(newGeneration1.CurrentGeneration[0, 1]);
            Assert.True(newGeneration1.CurrentGeneration[1, 1]);
            Assert.True(newGeneration1.CurrentGeneration[2, 1]);
            Assert.False(newGeneration1.CurrentGeneration[3, 1]);
            Assert.False(newGeneration1.CurrentGeneration[4, 1]);
            Assert.False(newGeneration1.CurrentGeneration[5, 1]);

            Assert.False(newGeneration1.CurrentGeneration[0, 2]);
            Assert.True(newGeneration1.CurrentGeneration[1, 2]);
            Assert.True(newGeneration1.CurrentGeneration[2, 2]);
            Assert.False(newGeneration1.CurrentGeneration[3, 2]);
            Assert.False(newGeneration1.CurrentGeneration[4, 2]);
            Assert.False(newGeneration1.CurrentGeneration[5, 2]);

            Assert.False(newGeneration1.CurrentGeneration[0, 3]);
            Assert.False(newGeneration1.CurrentGeneration[1, 3]);
            Assert.False(newGeneration1.CurrentGeneration[2, 3]);
            Assert.True(newGeneration1.CurrentGeneration[3, 3]);
            Assert.True(newGeneration1.CurrentGeneration[4, 3]);
            Assert.False(newGeneration1.CurrentGeneration[5, 3]);

            Assert.False(newGeneration1.CurrentGeneration[0, 4]);
            Assert.False(newGeneration1.CurrentGeneration[1, 4]);
            Assert.False(newGeneration1.CurrentGeneration[2, 4]);
            Assert.True(newGeneration1.CurrentGeneration[3, 4]);
            Assert.True(newGeneration1.CurrentGeneration[4, 4]);
            Assert.False(newGeneration1.CurrentGeneration[5, 4]);

            Assert.False(newGeneration1.CurrentGeneration[0, 5]);
            Assert.False(newGeneration1.CurrentGeneration[1, 5]);
            Assert.False(newGeneration1.CurrentGeneration[2, 5]);
            Assert.False(newGeneration1.CurrentGeneration[3, 5]);
            Assert.False(newGeneration1.CurrentGeneration[4, 5]);
            Assert.False(newGeneration1.CurrentGeneration[5, 5]);

            // Generation 2
            Assert.Equal(expectedGeneration2Number, newGeneration2.GenerationNumber);

            Assert.False(newGeneration2.CurrentGeneration[0, 0]);
            Assert.False(newGeneration2.CurrentGeneration[1, 0]);
            Assert.False(newGeneration2.CurrentGeneration[2, 0]);
            Assert.False(newGeneration2.CurrentGeneration[3, 0]);
            Assert.False(newGeneration2.CurrentGeneration[4, 0]);
            Assert.False(newGeneration2.CurrentGeneration[5, 0]);

            Assert.False(newGeneration2.CurrentGeneration[0, 1]);
            Assert.True(newGeneration2.CurrentGeneration[1, 1]);
            Assert.True(newGeneration2.CurrentGeneration[2, 1]);
            Assert.False(newGeneration2.CurrentGeneration[3, 1]);
            Assert.False(newGeneration2.CurrentGeneration[4, 1]);
            Assert.False(newGeneration2.CurrentGeneration[5, 1]);

            Assert.False(newGeneration2.CurrentGeneration[0, 2]);
            Assert.True(newGeneration2.CurrentGeneration[1, 2]);
            Assert.False(newGeneration2.CurrentGeneration[2, 2]);
            Assert.False(newGeneration2.CurrentGeneration[3, 2]);
            Assert.False(newGeneration2.CurrentGeneration[4, 2]);
            Assert.False(newGeneration2.CurrentGeneration[5, 2]);

            Assert.False(newGeneration2.CurrentGeneration[0, 3]);
            Assert.False(newGeneration2.CurrentGeneration[1, 3]);
            Assert.False(newGeneration2.CurrentGeneration[2, 3]);
            Assert.False(newGeneration2.CurrentGeneration[3, 3]);
            Assert.True(newGeneration2.CurrentGeneration[4, 3]);
            Assert.False(newGeneration2.CurrentGeneration[5, 3]);

            Assert.False(newGeneration2.CurrentGeneration[0, 4]);
            Assert.False(newGeneration2.CurrentGeneration[1, 4]);
            Assert.False(newGeneration2.CurrentGeneration[2, 4]);
            Assert.True(newGeneration2.CurrentGeneration[3, 4]);
            Assert.True(newGeneration2.CurrentGeneration[4, 4]);
            Assert.False(newGeneration2.CurrentGeneration[5, 4]);

            Assert.False(newGeneration2.CurrentGeneration[0, 5]);
            Assert.False(newGeneration2.CurrentGeneration[1, 5]);
            Assert.False(newGeneration2.CurrentGeneration[2, 5]);
            Assert.False(newGeneration2.CurrentGeneration[3, 5]);
            Assert.False(newGeneration2.CurrentGeneration[4, 5]);
            Assert.False(newGeneration2.CurrentGeneration[5, 5]);
        }
예제 #9
0
 public static void SetGenerationSize(GenerationSize t_generationSize)
 {
     s_generationSize = t_generationSize;
 }