private void PopulateSubmatrix(int startRow, int endRow, int startColumn, int endColumn) { List <int> shuffledValues = RandomListAccess.GetShuffledList(SudokuCell.GetInitialPossibleValueList()); int i = 0; for (int row = startRow; row <= endRow; row++) { for (int column = startColumn; column <= endColumn; column++) { this[row, column].SetValue(shuffledValues[i++]); } } }
/// <summary> /// Populates the game with a new start situation /// </summary> public void New(int numberOfCellsToFill) { // Create a blank game Clear(); // Generate solution //ISudokuGenerator iSudokuGenerator = new SudokuBruteForceGenerator(); ISudokuGenerator iSudokuGenerator = this; List <IntegerTriple> result = iSudokuGenerator.Generate(); if (result != null) { RandomListAccess.GetShuffledList(result).Take(numberOfCellsToFill).ToList().ForEach(cell => { SetValue(cell.Item1, cell.Item2, cell.Item3); }); } }
private void PopulateSubmatrix(int squareRow, int squareColumn) { List <int> shuffledValues = RandomListAccess.GetShuffledList(new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); int i = 0; for (int row = squareRow * 3; row <= squareRow * 3 + 2; row++) { for (int column = squareColumn * 3; column <= squareColumn * 3 + 2; column++) { _Game[row, column].Value = shuffledValues[i++]; } } }