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)); }
public Generation RewriteGeneration(Generation currentGeneration, Generation nextGeneration, Dimention dimentions) { currentGeneration.DimensionX = dimentions.RowEnd - dimentions.RowStart + 1; currentGeneration.DimensionY = dimentions.ColumnEnd - dimentions.ColumnStart + 1; currentGeneration.ClearContent(); for (int row = 0; row < currentGeneration.DimensionX; row++) { Region listRow = new Region(); for (int column = 0; column < currentGeneration.DimensionY; column++) { listRow.Add(nextGeneration.ReadValueXY(row + dimentions.RowStart, column + dimentions.ColumnStart)); } currentGeneration.WriteRow(listRow); } return currentGeneration; }
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); }
public Generation RewriteGeneration(Generation currentGeneration, Generation nextGeneration, Dimention dimentions) { currentGeneration.DimensionX = dimentions.RowEnd - dimentions.RowStart + 1; currentGeneration.DimensionY = dimentions.ColumnEnd - dimentions.ColumnStart + 1; currentGeneration.ClearContent(); for (int row = 0; row < currentGeneration.DimensionX; row++) { Region listRow = new Region(); for (int column = 0; column < currentGeneration.DimensionY; column++) { listRow.Add(nextGeneration.ReadValueXY(row + dimentions.RowStart, column + dimentions.ColumnStart)); } currentGeneration.WriteRow(listRow); } return(currentGeneration); }