Esempio n. 1
0
            public void GliderMovesBoundsUp()
            {
                var initial = new[]
                {
                    1, 1, 1,
                    0, 0, 1,
                    0, 1, 0,
                };
                var step1 = new[]
                {
                    0, 1, 0,
                    0, 1, 1,
                    1, 0, 1,
                    0, 0, 0,
                };

                var universe = new Universe(3, 3);

                universe.SetUniverse(initial);

                universe.Tick();

                UniverseAssert.Equal(step1, universe);
                UniverseAssert.BoundsEqual(-1, -2, 3, 4, universe);
            }
Esempio n. 2
0
            public void BarOscillates()
            {
                var step1 = new[]
                {
                    0, 0, 0, 0, 0,
                    0, 0, 1, 0, 0,
                    0, 0, 1, 0, 0,
                    0, 0, 1, 0, 0,
                    0, 0, 0, 0, 0,
                };
                var step2 = new[]
                {
                    0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0,
                    0, 1, 1, 1, 0,
                    0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0,
                };

                var universe = new Universe(5, 5);

                universe.SetUniverse(step1);

                var changed = universe.Tick();

                Assert.True(changed);

                UniverseAssert.Equal(step2, universe);

                changed = universe.Tick();
                Assert.True(changed);

                UniverseAssert.Equal(step1, universe);
            }
Esempio n. 3
0
            public void CellWithFourNeighborsStaysAlive()
            {
                var initial = new[]
                {
                    0, 0, 0, 0, 0,
                    0, 0, 1, 0, 0,
                    0, 1, 1, 1, 0,
                    0, 0, 1, 0, 0,
                    0, 0, 0, 0, 0,
                };

                var universe = new Universe(5, 5);

                universe.SetUniverse(initial);

                var changed = universe.Tick();

                Assert.True(changed);
                var expected = new[]
                {
                    0, 0, 0, 0, 0,
                    0, 1, 1, 1, 0,
                    0, 1, 0, 1, 0,
                    0, 1, 1, 1, 0,
                    0, 0, 0, 0, 0,
                };

                UniverseAssert.Equal(expected, universe);
            }
Esempio n. 4
0
            public void GliderMovesBoundsMultipleTimes()
            {
                var initial = new[]
                {
                    0, 1, 0,
                    0, 0, 1,
                    1, 1, 1,
                };
                var step1 = new[]
                {
                    0, 0, 0,
                    1, 0, 1,
                    0, 1, 1,
                    0, 1, 0,
                };
                var step2 = new[]
                {
                    0, 0, 0,
                    0, 0, 1,
                    1, 0, 1,
                    0, 1, 1,
                };
                var step3 = new[]
                {
                    0, 0, 0, 0,
                    0, 1, 0, 0,
                    0, 0, 1, 1,
                    0, 1, 1, 0,
                };

                var universe = new Universe(3, 3);

                universe.SetUniverse(initial);

                universe.Tick();
                UniverseAssert.Equal(step1, universe);
                UniverseAssert.BoundsEqual(-1, -1, 3, 4, universe);

                universe.Tick();
                UniverseAssert.Equal(step2, universe);
                UniverseAssert.BoundsEqual(-1, -1, 3, 4, universe);

                universe.Tick();
                UniverseAssert.Equal(step3, universe);
                UniverseAssert.BoundsEqual(-1, -1, 4, 4, universe);
            }
Esempio n. 5
0
            public void DiamondPatternStaysTheSame()
            {
                var initial = new[]
                {
                    0, 0, 0, 0, 0, 0,
                    0, 0, 1, 1, 0, 0,
                    0, 1, 0, 0, 1, 0,
                    0, 0, 1, 1, 0, 0,
                    0, 0, 0, 0, 0, 0,
                };

                var universe = new Universe(6, 5);

                universe.SetUniverse(initial);

                var changed = universe.Tick();

                Assert.False(changed);
                UniverseAssert.Equal(initial, universe);
            }
Esempio n. 6
0
            public void CellWithOnlyThreeNeighborsStaysAlive()
            {
                var initial = new[]
                {
                    0, 0, 0, 0, 0,
                    0, 1, 1, 0, 0,
                    0, 1, 1, 0, 0,
                    0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0,
                };

                var universe = new Universe(5, 5);

                universe.SetUniverse(initial);

                var changed = universe.Tick();

                Assert.False(changed);
                UniverseAssert.Equal(initial, universe);
            }