public int GetBlockWidth() { if (_board != null) { return(_board.GetBlockWidth()); } else { throw new GameNotStartedException(); } }
private bool SearchRowForValuesThatOnlyFitInOneBlock(int row) { List <int> possibleValuesInRowInBlock; bool changes = false; for (int i = 0; i != _board.GetBoardSize(); i += _board.GetBlockWidth()) { possibleValuesInRowInBlock = GetPossibleValuesInSectionInBlock(_board.GetRowCells(row), i, _board.GetBlockWidth()); foreach (int value in possibleValuesInRowInBlock) { //Sjekker om det finnes verdier i raden som bare kan puttes i den gitte blokken, og fjerner eventuelt verdiene i blokken som ikke ligger på samme rad bool uniqueValue = CheckIfPossibleValueOnlyExistsInBlockInSelection(_board.GetRowCells(row), value, i, _board.GetBlockWidth()); if (uniqueValue == true) { for (int j = 0; j < _board.GetBoardSize(); j++) { if ((row != GetRowFromBlockPosition(row, j)) && (possibleValues[GetRowFromBlockPosition(row, j), GetColumnFromBlockPosition(i, j)].Contains(value) == true)) { possibleValues[GetRowFromBlockPosition(row, j), GetColumnFromBlockPosition(i, j)].Remove(value); changes = true; } } } //Sjekker om det finnes verdier i blokken som bare kan puttes i den gitte raden, og fjerner eventuelt verdiene i raden som ikke ligger i samme blokk uniqueValue = CheckIfPossibleValueOnlyExistsInRowInBlock(_board.GetBlockCells(row, i), value, _board.GetBlockWidth(), row); if (uniqueValue == true) { for (int j = 0; j != _board.GetBoardSize(); j++) { if (((j < i) || (j >= (i + _board.GetBlockWidth()))) && (possibleValues[row, j].Contains(value) == true)) { possibleValues[row, j].Remove(value); changes = true; } } } } } return(changes); }