Esempio n. 1
0
        static void Main(string[] args)
        {
            int runs = 0;
            int height, width, maxRuns;

            // Get the INput Values
            Console.Write("Enter Board Height : ");
            int.TryParse(Console.ReadLine(), out height);

            Console.Write("Enter Board Width : ");
            int.TryParse(Console.ReadLine(), out width);

            Console.Write("Enter Number of Generation : ");
            int.TryParse(Console.ReadLine(), out maxRuns);

            // Validate the values and if values are not int, then exit from program
            if (height == 0 || width == 0 || maxRuns == 0)
            {
                Console.Write("Value for Height, Width and NUmbe of Generation must be greater then 0");
                Console.ReadLine();
                return;
            }
            // Display a message for  Board
            GameOfLife gm = new GameOfLife(height, width);

            Console.WriteLine("\r");
            Console.Write("Generating a Bord of {0} X {1}, will run for {2}", height.ToString(), width.ToString(), maxRuns.ToString());
            Console.WriteLine("\r");
            // Run the Program
            while (runs++ < maxRuns)
            {
                gm.StartGame();
                System.Threading.Thread.Sleep(1000);
            }

            Console.ReadKey();
        }