This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
package sudoku.solver;
|
||||
|
||||
import sudoku.io.SudokuPrinter;
|
||||
import sudoku.structure.MultiDoku;
|
||||
import sudoku.structure.Cell;
|
||||
import sudoku.structure.Sudoku;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Solver {
|
||||
private static final Logger logger = Logger.getLogger("SolverLogger");
|
||||
|
||||
/**
|
||||
* Résout le multidoku passé en paramètre si c'est possible.
|
||||
@@ -21,6 +26,9 @@ public class Solver {
|
||||
if (Thread.interrupted())
|
||||
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()));
|
||||
|
||||
if (doku.isValid()) {
|
||||
return true;
|
||||
}
|
||||
@@ -32,7 +40,7 @@ public class Solver {
|
||||
|
||||
List<Integer> possibleSymbols = doku.getPossibleSymbolsOfCell(cellToFill);
|
||||
|
||||
while (!possibleSymbols.isEmpty()){
|
||||
while (!possibleSymbols.isEmpty()) {
|
||||
int nextPossibleSymbolIndex = rand.nextInt(possibleSymbols.size());
|
||||
int nextSymbol = possibleSymbols.get(nextPossibleSymbolIndex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user