Beispiel #1
0
        static void Main(string[] args)
        {
            //Initialize
            Console.SetWindowSize(maxX + 10, maxY + 10);
            Console.SetWindowPosition(0, 0);

            //Random initial positions
            Random r = new Random((int)DateTime.Now.Ticks);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    field[x, y] = r.Next(0, 1 + 1);
                }
            }

            //Instantiate the desired concrete RuleSet in this Strategy pattern
            RuleSet ruleSet = new ConwaysGameOfLife(field, maxX, maxY);

            for (int i = 0; i < 5000; i++)
            {
                DrawField();
                ruleSet.Tick();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //Initialize
            Console.SetWindowSize(maxX + 10, maxY + 10);
            Console.SetWindowPosition(0, 0);

            //Random initial positions
            Random r = new Random((int)DateTime.Now.Ticks);
            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    field[x, y] = r.Next(0, 1 + 1);
                }
            }

            //Instantiate the desired concrete RuleSet in this Strategy pattern
            RuleSet ruleSet = new ConwaysGameOfLife(field, maxX, maxY);

            for (int i = 0; i < 5000; i++)
            {
                DrawField();
                ruleSet.Tick();
            }
        }