Пример #1
0
        static void Main(string[] args)
        {
            _cells = new Cell[_gridSize, _gridSize];

            // Population
            for (int x = 0; x < _gridSize; x++)
            {
                for (int y = 0; y < _gridSize; y++)
                {
                    bool active = _random.Next(1, 100) <= _birthChanceAtStart;
                    Cell cell   = new Cell(x, y, active, _cells);
                    _cells[x, y] = cell;
                }
            }

            // Generations
            for (int g = 0; g < _maxGenerations; g++)
            {
                Paint(g);
                Thread.Sleep(1000 / _generationsPerSecond);

                for (int x = 0; x < _gridSize; x++)
                {
                    for (int y = 0; y < _gridSize; y++)
                    {
                        Cell cell = _cells[x, y];
                        if (cell.IsDead())
                        {
                            cell.Die();
                        }
                        else
                        {
                            cell.Ressurect();
                        }
                    }
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            _cells = new Cell[_gridSize, _gridSize];

            // Population
            for (int x = 0; x < _gridSize; x++)
            {
                for (int y = 0; y < _gridSize; y++)
                {
                    bool active = _random.Next(1, 100) <= _birthChanceAtStart;
                    Cell cell = new Cell(x, y, active, _cells);
                    _cells[x, y] = cell;
                }
            }

            // Generations
            for (int g = 0; g < _maxGenerations; g++)
            {
                Paint(g);
                Thread.Sleep(1000 / _generationsPerSecond);

                for (int x = 0; x < _gridSize; x++)
                {
                    for (int y = 0; y < _gridSize; y++)
                    {
                        Cell cell = _cells[x, y];
                        if (cell.IsDead())
                            cell.Die();
                        else
                            cell.Ressurect();
                    }
                }
            }
        }