feat : logger
Some checks failed
Linux arm64 / Build (push) Has been cancelled

This commit is contained in:
Melvyn
2025-01-28 09:59:51 +01:00
parent b1ae79a2e8
commit ebb3a4c48a
4 changed files with 48 additions and 8 deletions

View File

@@ -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);