Ejemplo n.º 1
0
        public LifeGame(int x,int y)
        {
            cellsX = x;
            cellsY = y;

            Cells = new Cells(cellsX,cellsY);
            nextCells = new Cells(cellsX,cellsY);
            DrawFlags = new bool[cellsX, cellsY];
            for (var j = 0; j < cellsY; j++)
            {
                for (var i = 0; i < cellsX; i++)
                {
                    Cells[i, j] = 0;
                    DrawFlags[i, j] = true;
                }
            }
        }
Ejemplo n.º 2
0
        public void OnFrame()
        {
            for (var j = 0; j < cellsY; j++)
            {
                for (var i = 0; i < cellsX; i++)
                {
                    if (Cells[i, j] == 0)
                    {
                        if (CellsCount(i, j) == 3)
                        {
                            nextCells[i, j] = 1;
                            DrawFlags[i, j] = true;
                        }
                        else
                        {
                            nextCells[i, j] = 0;
                            DrawFlags[i, j] = false;
                        }
                    }
                    else
                    {
                        if (CellsCount(i, j) == 2 || CellsCount(i,j) == 3)
                        {
                            nextCells[i, j] = 1;
                            DrawFlags[i, j] = false;
                        }
                        else
                        {
                            nextCells[i, j] = 0;
                            DrawFlags[i, j] = true;
                        }
                    }
                }
            }

            bufCells = Cells;
            Cells = nextCells;
            nextCells = bufCells;
        }