Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int  width = 50, height = 30, borderwidth = 1;
            char livingCell = 'o', deadCell = ' ';
            int  value;

            Console.SetCursorPosition(0, 0);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Выберите режим игры:");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("1.Автоматический режим");
            Console.WriteLine("2.Ручной режим (переход к следующему шагу по нажатию Enter)");
            value = Convert.ToInt32(Console.ReadLine());
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("                         Инструкция");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Для того чтобы поставить/удалить клетку - нажмите кнопку Space");
            Console.WriteLine("Игра будет начата через 10 секунд...");
            Thread.Sleep(10000);
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            GameOfLife.CreateInstance(width, height, borderwidth, livingCell, deadCell, value);
            GameOfLife.GetDrawing();
            GameOfLife.Start();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            while (true)
            {
                int width;
                int height;
                int borderWidth = 1;
                int delay;

                int minNeighbour;
                int maxNeighbour;
                int reqNeighbour;

                char livingCell = 'X';
                char deadCell   = ' ';

                Console.Write("Board widht:");
                width = Convert.ToInt32(Console.ReadLine());
                Console.Write("Board height:");
                height = Convert.ToInt32(Console.ReadLine());
                Console.Write("Delay(in ms):");
                delay = Convert.ToInt32(Console.ReadLine());

                Console.Write("Minimum neighbour:");
                minNeighbour = Convert.ToInt32(Console.ReadLine());
                Console.Write("Maximum neighbour:");
                maxNeighbour = Convert.ToInt32(Console.ReadLine());
                Console.Write("Neighbour(s) required to reproduce:");
                reqNeighbour = Convert.ToInt32(Console.ReadLine());

                Console.Clear();

                GameOfLife.CreateInstance(width, height, borderWidth, ConsoleColor.Black, ConsoleColor.DarkGreen, livingCell, deadCell, delay, minNeighbour, maxNeighbour, reqNeighbour);
                GameOfLife.StartGame();

                //Population is stagnant / died
                Console.WriteLine("Press any key to restart");
                Console.ReadLine();
                Console.Clear();
            }
        }