Esempio n. 1
0
        static void Main(string[] args)
        {
            var grid = new LifeGrid(NumberOfRows, NumberOfColumns);
            var randomGridSeeder = new RandomGridSeeder();
            randomGridSeeder.Seed(grid);

            while (true)
            {
                grid.Tick();

                var cells = grid.GetLivingCells();
                DisplayCells(cells);
                Thread.Sleep(500);
            }
        }
Esempio n. 2
0
        public void Seed(LifeGrid grid)
        {
            var random = new Random();

            for (var x = 0; x < grid.NumberOfColumns; x++)
            {
                for (var y = 0; y < grid.NumberOfRows; y++)
                {
                    var randomNumber = random.Next(0, 5);

                    if (randomNumber == 1)
                        grid.BringToLife(y + 1, x + 1);
                }
            }
        }
Esempio n. 3
0
        public void Seed(LifeGrid grid)
        {
            var random = new Random();

            for (var x = 0; x < grid.NumberOfColumns; x++)
            {
                for (var y = 0; y < grid.NumberOfRows; y++)
                {
                    var randomNumber = random.Next(0, 5);

                    if (randomNumber == 1)
                    {
                        grid.BringToLife(y + 1, x + 1);
                    }
                }
            }
        }
Esempio n. 4
0
        protected void backgroundWorker_DoWork(Object sender, DoWorkEventArgs e)
        {
            var grid = new LifeGrid(NumberOfRows, NumberOfColumns);
            var randomGridSeeder = new RandomGridSeeder();
            randomGridSeeder.Seed(grid);

            while (true)
            {
                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                grid.Tick();

                var cells = grid.GetLivingCells();
                backgroundWorker.ReportProgress(0, cells);
                Thread.Sleep(TickDelay);
            }
        }
Esempio n. 5
0
 public void TestInitialize()
 {
     grid = new LifeGrid(1000, 1000);
     var randomGridSeeder = new RandomGridSeeder();
     randomGridSeeder.Seed(grid);
 }
Esempio n. 6
0
 public void TestInitialize()
 {
     grid = new LifeGrid(4, 4);
 }