Ejemplo n.º 1
0
 public StandardLife(int inSize)
 {
     this._size = inSize;
     cells      = new StandardCell[_size, _size];
     for (int row = 0; row < _size; row++)
     {
         for (int column = 0; column < _size; column++)
         {
             cells[row, column] = new StandardCell();
         }
     }
 }
Ejemplo n.º 2
0
 public StandardLife(int inSize)
 {
     this._size = inSize;
     cells = new StandardCell[_size,_size];
     for (int row =0; row < _size; row++)
     {
         for (int column = 0; column < _size; column++)
         {
             cells[row, column] = new StandardCell();
         }
     }
 }
Ejemplo n.º 3
0
        public override void Iterate()
        {
            StandardCell[,] newCells = new StandardCell[_size, _size];

            for (int row = 0; row < _size; row++)
            {
                for (int column = 0; column < _size; column++)
                {
                    int living = countLivingSurroundingCells(row, column);
                    //standard conway rules: https://en.wikipedia.org/wiki/Conway's_Game_of_Life
                    if (GetCell(row, column).IsAlive)
                    {
                        if (living == 2 || living == 3)
                        {
                            newCells[row, column] = new StandardCell(true); //alive
                        }
                        else
                        {
                            newCells[row, column] = new StandardCell(); //dead
                        }
                    }
                    else
                    {
                        if (living == 3)
                        {
                            newCells[row, column] = new StandardCell(true); //alive
                        }
                        else
                        {
                            newCells[row, column] = new StandardCell(); //dead
                        }
                    }
                }
            }
            cells = newCells;
        }
Ejemplo n.º 4
0
        public override void Iterate()
        {
            StandardCell[,] newCells = new StandardCell[_size,_size];

            for (int row = 0; row < _size; row++)
            {
                for (int column = 0; column < _size; column++)
                {
                    int living = countLivingSurroundingCells(row, column);
                    //standard conway rules: https://en.wikipedia.org/wiki/Conway's_Game_of_Life
                    if (GetCell(row, column).IsAlive) {
                        if (living == 2 || living == 3)
                        {
                            newCells[row,column] = new StandardCell(true); //alive
                        }
                        else
                        {
                            newCells[row,column] = new StandardCell(); //dead
                        }
                    }
                    else
                    {
                        if (living == 3)
                        {
                            newCells[row, column] = new StandardCell(true); //alive
                        }
                        else
                        {
                            newCells[row, column] = new StandardCell(); //dead
                        }
                    }
                }
            }
            cells = newCells;
                    
        }