aaaaaaaaaaaaaaaaaaaaaaaaaaaa
All checks were successful
Linux arm64 / Build (push) Successful in 32s
All checks were successful
Linux arm64 / Build (push) Successful in 32s
This commit is contained in:
@@ -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,11 +59,11 @@ public class MixedSolver implements Solver {
|
||||
if (possibleSymbols.size() == 1) {
|
||||
cell.setSymbolIndex(possibleSymbols.getFirst());
|
||||
addStep(cell, steps);
|
||||
}
|
||||
}
|
||||
|
||||
if (doku.isSolved())
|
||||
if (solve(doku, steps))
|
||||
return true;
|
||||
cell.setSymbolIndex(Cell.NOSYMBOL);
|
||||
}
|
||||
}
|
||||
|
||||
// on ne peut plus remplir de cases, on tente de backtrack
|
||||
for (int maxPossibilities = 2; maxPossibilities <= symbolCount; maxPossibilities++) {
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user