aaaaaaaaaaaaaaaaaaaaaaaaaaaa
All checks were successful
Linux arm64 / Build (push) Successful in 32s

This commit is contained in:
2025-02-02 20:17:54 +01:00
parent 9c72891048
commit b68fe81914

View File

@@ -45,6 +45,9 @@ public class MixedSolver implements Solver {
throw new CancellationException("User wants to stop the solver");
}
if (doku.isSolved())
return true;
int symbolCount = doku.getSubGrid(0).getSize();
// on remplit les cases par déduction
@@ -56,12 +59,12 @@ public class MixedSolver implements Solver {
if (possibleSymbols.size() == 1) {
cell.setSymbolIndex(possibleSymbols.getFirst());
addStep(cell, steps);
if (solve(doku, steps))
return true;
cell.setSymbolIndex(Cell.NOSYMBOL);
}
}
if (doku.isSolved())
return true;
// on ne peut plus remplir de cases, on tente de backtrack
for (int maxPossibilities = 2; maxPossibilities <= symbolCount; maxPossibilities++) {
List<Cell> backtrackCells = new ArrayList<>();
@@ -81,15 +84,12 @@ public class MixedSolver implements Solver {
// on tente de placer chacun des symboles
for (int symbol : possibilities) {
var state = doku.getStateManager().pushState();
backtrackCell.setSymbolIndex(symbol);
if (solve(doku, steps)) {
// doku.getStateManager().forgetState();
return true;
}
doku.getStateManager().popState();
doku.getStateManager().restoreState(state);
}
backtrackCell.setSymbolIndex(Cell.NOSYMBOL);
}
}
return doku.isSolved();