Esempio n. 1
0
 public universe(int x, int y)
 {
     Max_X         = x;
     Max_Y         = y;
     nextCellState = new bool[Max_X, Max_Y];
     cells         = new cell[Max_X, Max_Y];
     for (int mx = 0; mx < Max_X; mx++)
     {
         for (int my = 0; my < Max_Y; my++)
         {
             cells[mx, my]       = new cell();
             cells[mx, my].State = false;
         }
     }
 }
Esempio n. 2
0
        private void setupGrid(int rows, int cols, int density)
        {
            Random r = new Random();

            this.grid = new cell[rows, cols];

            for (int i = 0; i < grid.GetLength(0); i++)
            {
                for (int j = 0; j < grid.GetLength(1); j++)
                {
                    int x = r.Next(0, density);
                    switch (x)
                    {
                    case 0:
                        grid[i, j] = new cell("X");
                        break;

                    default:
                        grid[i, j] = new cell(" ");
                        break;
                    }
                }
            }
        }