예제 #1
0
        /// <summary>
        /// Initializes the cells array according to the passed rule
        /// </summary>
        private void InitializeCells(IRule initialRule)
        {
            Cells = new Cell[RowsCount, ColumnsCount];

            Parallel.For(0, RowsCount, row =>
            {
                Parallel.For(0, ColumnsCount, col =>
                {
                    var cell = new Cell(row, col);

                    if (initialRule.Condition(cell, this))
                    {
                        initialRule.Action(cell);
                    }

                    if (cell.State == CellState.Alive)
                    {
                        AliveCount++;
                    }

                    Cells[row, col] = cell;
                });
            });
        }