This commit is contained in:
@@ -16,7 +16,8 @@ public class Solver {
|
||||
|
||||
/**
|
||||
* Résout le multidoku passé en paramètre si c'est possible.
|
||||
* En testant toutes les possibilités, de manière aléatoire, avec un algorithme de backtracking.
|
||||
* En testant toutes les possibilités, de manière aléatoire, avec un algorithme
|
||||
* de backtracking.
|
||||
*
|
||||
* @param doku Multidoku, à résoudre
|
||||
* @param rand Random, pour tester aléatoirement les symboles
|
||||
@@ -24,10 +25,13 @@ public class Solver {
|
||||
*/
|
||||
public static boolean solveRandom(MultiDoku doku, Random rand) {
|
||||
if (Thread.interrupted())
|
||||
throw new CancellationException("User wants to stop the solver");
|
||||
throw new CancellationException("User wants to stop the solver");
|
||||
|
||||
Sudoku sudoku = doku.getSubGrid(0);
|
||||
logger.log(Level.INFO, '\n'+SudokuPrinter.toStringRectangleSudoku(sudoku, sudoku.getSize(), sudoku.getSize()));
|
||||
logger.log(Level.INFO,
|
||||
'\n' + SudokuPrinter.toStringRectangleSudoku(sudoku,
|
||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getBlockWidth(),
|
||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getSize() / sudoku.getBlockWidth()));
|
||||
|
||||
if (doku.isValid()) {
|
||||
return true;
|
||||
@@ -83,7 +87,7 @@ public class Solver {
|
||||
|
||||
public static boolean solve(MultiDoku doku) {
|
||||
if (Thread.interrupted())
|
||||
throw new CancellationException("User wants to stop the solver");
|
||||
throw new CancellationException("User wants to stop the solver");
|
||||
|
||||
if (doku.isValid()) {
|
||||
return true;
|
||||
@@ -99,7 +103,7 @@ public class Solver {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int symbol : possibleSymbols){
|
||||
for (int symbol : possibleSymbols) {
|
||||
|
||||
cellToFill.setSymbolIndex(symbol);
|
||||
if (Solver.solve(doku)) {
|
||||
|
||||
Reference in New Issue
Block a user