Example #1
0
        public Generation RefillGeneration(Generation currentGeneration)
        {
            Generation nextGeneration = new Generation();

            nextGeneration.DimensionX = currentGeneration.DimensionX + currentGeneration.Increase * 2;
            nextGeneration.DimensionY = currentGeneration.DimensionY + currentGeneration.Increase * 2;

            for (int row = 0; row < nextGeneration.DimensionX; row++)
            {
                Region listRow = new Region();
                for (int column = 0; column < nextGeneration.DimensionY; column++)
                {
                    CheckFieldModification check = new CheckFieldModification(currentGeneration, row - currentGeneration.Increase, column - currentGeneration.Increase);
                    listRow.Add(check.CheckStatusForNeighbours());
                    check.Dispose();
                }
                nextGeneration.WriteRow(listRow);
            }
            if (_checkDimension.CheckFieldRows(nextGeneration, 0, 1) == -1)
            {
                currentGeneration.ClearContent(); return(currentGeneration);
            }
            _dimentions = new Dimention(currentGeneration.DimensionX, currentGeneration.DimensionY);
            if (currentGeneration.Increase > 0)
            {
                CheckDimentions(nextGeneration);
            }
            return(_makeChange.RewriteGeneration(currentGeneration, nextGeneration, _dimentions));
        }
Example #2
0
        public Generation RefillGeneration(Generation currentGeneration)
        {
            Generation nextGeneration = new Generation();
            nextGeneration.DimensionX = currentGeneration.DimensionX + currentGeneration.Increase * 2;
            nextGeneration.DimensionY = currentGeneration.DimensionY + currentGeneration.Increase * 2;

            for (int row = 0; row < nextGeneration.DimensionX; row++)
            {
                Region listRow = new Region();
                for (int column = 0; column < nextGeneration.DimensionY; column++)
                {
                    CheckFieldModification check = new CheckFieldModification(currentGeneration, row - currentGeneration.Increase, column - currentGeneration.Increase);
                    listRow.Add(check.CheckStatusForNeighbours());
                    check.Dispose();
                }
                nextGeneration.WriteRow(listRow);
            }
            if (_checkDimension.CheckFieldRows(nextGeneration, 0, 1) == -1) { currentGeneration.ClearContent(); return currentGeneration; }
            _dimentions = new Dimention(currentGeneration.DimensionX, currentGeneration.DimensionY);
            if (currentGeneration.Increase > 0) CheckDimentions(nextGeneration);
            return _makeChange.RewriteGeneration(currentGeneration, nextGeneration, _dimentions);
        }