示例#1
0
        public void ChangeStateTest()
        {
            uint size = 25;
            GameOfLife gof = new GameOfLife(size);

            int? oldState = gof[0, 0];

            CoordState stateChange;
            if (oldState == null)
            {
                stateChange = new CoordState(0, 0, 1);
            }
            else
            {
                stateChange = new CoordState(0, 0, null);
            }

            gof.ChangeState(stateChange);

            int? newState = gof[0, 0];

            Assert.AreNotEqual(oldState, newState);
        }
示例#2
0
        static void Main(string[] args)
        {
            //Console
            /*
            ConsoleKeyInfo cki;

            GameOfLife gof = new GameOfLife(25);
            gof.RandomizeWorld(new Random());
            gof.PrintWorld();

            do
            {
                cki = Console.ReadKey();
                gof.NextDay();
                Console.WriteLine();
                gof.PrintWorld();
            } while (cki.Key != ConsoleKey.Q);
            */

            //GUI
            IGameOfLife gof = new GameOfLife(25);
            GOFRunner.Run(gof);
        }
示例#3
0
        public void NextDayTest()
        {
            uint size = 25;
            GameOfLife gof = new GameOfLife(size);
            Random rnd = new Random();
            gof.RandomizeWorld(rnd);
            int?[,] world1 = new int?[size, size];
            for (uint x = 0; x < size; x++)
            {
                for (uint y = 0; y < size; y++)
                {
                    world1[x, y] = gof[x, y];
                }
            }

            //Make a day go by
            gof.NextDay();

            int?[,] world2 = new int?[size, size];
            for (uint x = 0; x < size; x++)
            {
                for (uint y = 0; y < size; y++)
                {
                    world2[x, y] = gof[x, y];
                }
            }
            Assert.AreNotEqual(world1, world2);
        }
示例#4
0
 public void GameOfLifeConstructorTest()
 {
     uint size = 25;
     GameOfLife gof = new GameOfLife(size);
     Assert.AreEqual(size, gof.Size);
 }
示例#5
0
        public void RandomizeWorldTest()
        {
            uint size = 25;
            GameOfLife gof1337 = new GameOfLife(size);
            Random rnd = new Random(1337);
            gof1337.RandomizeWorld(rnd);
            int?[,] world1337 = new int?[size, size];
            for (uint x = 0; x < size; x++)
            {
                for (uint y = 0; y < size; y++)
                {
                    world1337[x, y] = gof1337[x, y];
                }
            }

            GameOfLife gof42 = new GameOfLife(size);
            rnd = new Random(42);
            gof42.RandomizeWorld(rnd);
            int?[,] world42 = new int?[size, size];
            for (uint x = 0; x < size; x++)
            {
                for (uint y = 0; y < size; y++)
                {
                    world42[x, y] = gof42[x, y];
                }
            }
            Assert.AreNotEqual(world1337, world42);
        }