Example #1
0
        public void Mutate()
        {
            var newWorld = World.EmptyClone();

            foreach(var x in Range(World.Dimension))
                foreach(var y in Range(World.Dimension))
                    newWorld[x, y] = GetMutatedState(x, y);

            World = newWorld;
        }
Example #2
0
        public void Blinker()
        {
            var preCells = new World(new int[,] {
                { 0, 0, 0 },
                { 1, 1, 1 },
                { 0, 0, 0 }
            });

            var postCells = new World(new int[,] {
                { 0, 1, 0 },
                { 0, 1, 0 },
                { 0, 1, 0 }
            });

            TestMutation(preCells, postCells);
        }
Example #3
0
        public void Block()
        {
            var preCells = new World(new int[,] {
                { 0, 0, 0, 0 },
                { 0, 1, 1, 0 },
                { 0, 1, 1, 0 },
                { 0, 0, 0, 0 }
            });

            var afterCells = new World(new int[,] {
                { 0, 0, 0, 0 },
                { 0, 1, 1, 0 },
                { 0, 1, 1, 0 },
                { 0, 0, 0, 0 }
            });

            TestMutation(preCells, afterCells);
        }
Example #4
0
 public bool Equals(World other)
 {
     return GetHashCode() == other.GetHashCode();
 }
Example #5
0
 public GameOfLife(World world)
 {
     World = world;
 }
Example #6
0
        public void ZeroCellsShouldMutateToZeroCells()
        {
            var preCells = new World(new int[,] {{}});

            var afterCells = new World(new int[,] {{}});

            TestMutation(preCells, afterCells);
        }
Example #7
0
        void TestMutation(World pre, World post)
        {
            var game = new GameOfLife(pre);
            game.Mutate();

            Assert.That(game.World, Is.EqualTo(post));
        }