Exemplo n.º 1
0
 private void nextToolStripMenuItem_Click(object sender, EventArgs e)
 {
     l.Next();
     show();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string[] fileStrings = File.ReadAllLines("LifeGameInitial.txt");
            //int Height = File.ReadAllLines("LifeGameInitial.txt").Length;
            int Height = File.ReadLines(@"LifeGameInitial.txt").Count();
            int Width  = File.ReadAllLines(@"LifeGameInitial.txt")[0].Length;


            Life   life          = new Life(Height, Width, true);
            string consoleAnswer = "N";

            VladBolotin vb = new VladBolotin();

            do
            {
                int i        = 1;
                int MaxCount = 100;

                Console.WriteLine("Game life started");
                Console.WriteLine("How many steps in the game ?");
                MaxCount = Convert.ToInt32(Console.ReadLine());


                //life.initCurrentArray.initFillSomeColony(); // test case
                //life.initCurrentArray.initFill3PointsInLine(); // test case
                if (life.IsInitFromFile)
                {
                    life.initCurrentArray.FromFile();
                }
                else
                {
                    life.initCurrentArray.FillSomeColony();
                }

                vb.initFillAllZero();
                vb.InitState();

                //life.showArray(life.CurrentArray);
                //Console.ReadLine();

                do
                {
                    Console.Clear();
                    Console.WriteLine("step " + i.ToString() + "/" + MaxCount.ToString());
                    if (!life.Next())
                    {
                        Console.WriteLine("Apocalypsis happened");
                        break;
                    }
                    vb.NextState();
                    Console.WriteLine("Stas                        Vlad");
                    for (int k = 0; k < life.W; k++)
                    {
                        Console.Write("-");
                    }
                    Console.WriteLine();
                    //life.showArray(life.NextArray);
                    life.showBothArrays(life.NextArray, vb.LifeArrayNextStep);
                    Console.WriteLine();
                    for (int k = 0; k < life.W; k++)
                    {
                        Console.Write("-");
                    }
                    i++;

                    Thread.Sleep(6000);
                }while (i != MaxCount + 1);
                Console.WriteLine();
                Console.WriteLine("Game over");
                Console.WriteLine("One more game Y/N ?");
                consoleAnswer = Convert.ToString(Console.ReadLine());
            }while (consoleAnswer == "Y");
            Console.WriteLine("Stas games development inc. All right reserved");
            Console.Read();
        }