feat: add history
This commit is contained in:
@@ -11,17 +11,17 @@ import sudoku.structure.Cell;
|
||||
import sudoku.structure.MultiDoku;
|
||||
import sudoku.structure.Sudoku;
|
||||
|
||||
public class MixedSolver implements Solver{
|
||||
public class MixedSolver implements Solver {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Résout le MultiDoku passé en paramètre, avec règles de déduction et
|
||||
* backtracking.
|
||||
*
|
||||
* @param doku MultiDoku, MultiDoku à résoudre.
|
||||
* @return boolean, valant true si le MultiDoku est résolu, false sinon.
|
||||
*/
|
||||
@Override
|
||||
public boolean solve(MultiDoku doku) {
|
||||
@Override
|
||||
public boolean solve(MultiDoku doku, List<SolverStep> steps) {
|
||||
Random rand = new Random();
|
||||
|
||||
if (Thread.interrupted()) {
|
||||
@@ -49,6 +49,7 @@ public class MixedSolver implements Solver{
|
||||
|
||||
if (possibleSymbols.size() == 1) {
|
||||
cellToFill.setSymbolIndex(possibleSymbols.getFirst());
|
||||
addStep(cellToFill, steps);
|
||||
if (this.solve(doku)) {
|
||||
return true;
|
||||
}
|
||||
@@ -59,10 +60,12 @@ public class MixedSolver implements Solver{
|
||||
int nextSymbol = possibleSymbols.get(nextPossibleSymbolIndex);
|
||||
|
||||
cellToFill.setSymbolIndex(nextSymbol);
|
||||
addStep(cellToFill, steps);
|
||||
if (this.solve(doku)) {
|
||||
return true;
|
||||
}
|
||||
cellToFill.setSymbolIndex(Cell.NOSYMBOL);
|
||||
addStep(cellToFill, steps);
|
||||
possibleSymbols.remove(nextPossibleSymbolIndex);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user