private int DetermineCountOfNeighbours(int row, int column) { if (row >= 0 && row < _currentGeneration.DimensionX && column >= 0 && column < _currentGeneration.DimensionY) { if (_currentGeneration.ReadValueXY(row, column) > 0) { return(1); } } return(0); }
public void PrintResult(Generation currentGeneration) { for (int row = 0; row < currentGeneration.DimensionX; row++) { for (int column = 0; column < currentGeneration.DimensionY; column++) { if (currentGeneration.ReadValueXY(row, column) != 0) { currentGeneration.WriteValueXY(row, column, 1); Console.Write((char)currentGeneration.ReadValueXY(row, column)); } else { Console.Write(" "); } } Console.WriteLine(); } }
public void PrintResult(Generation currentGeneration) { for (int row = 0; row < currentGeneration.DimensionX; row++) { for (int column = 0; column < currentGeneration.DimensionY; column++) { if (currentGeneration.ReadValueXY(row, column) != 0) { currentGeneration.WriteValueXY(row, column, 1); Console.Write((char)currentGeneration.ReadValueXY(row, column)); } else { Console.Write(" "); } } Console.WriteLine(); } }
public int CheckFieldRows(Generation nextGeneration, int row, int step) { for (int i = row; i < nextGeneration.DimensionX && i >= 0; i += step) { for (int j = 0; j < nextGeneration.DimensionY; j++) { if (nextGeneration.ReadValueXY(i, j) == 1) return i; } } return -1; }
public int CheckFieldColumns(Generation nextGeneration, int column, int step) { for (int j = column; j < nextGeneration.DimensionY && j >= 0; j += step) { for (int i = 0; i < nextGeneration.DimensionX; i++) { if (nextGeneration.ReadValueXY(i, j) == 1) return j; } } return -1; }
public int CheckFieldRows(Generation nextGeneration, int row, int step) { for (int i = row; i < nextGeneration.DimensionX && i >= 0; i += step) { for (int j = 0; j < nextGeneration.DimensionY; j++) { if (nextGeneration.ReadValueXY(i, j) == 1) { return(i); } } } return(-1); }
public int CheckFieldColumns(Generation nextGeneration, int column, int step) { for (int j = column; j < nextGeneration.DimensionY && j >= 0; j += step) { for (int i = 0; i < nextGeneration.DimensionX; i++) { if (nextGeneration.ReadValueXY(i, j) == 1) { return(j); } } } return(-1); }
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 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; }