This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package gui.menu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
|
||||
import gui.widget.SudokuRenderer;
|
||||
@@ -11,6 +13,7 @@ import sudoku.solver.HintHelper;
|
||||
import sudoku.solver.HumanSolver;
|
||||
import sudoku.solver.MixedSolver;
|
||||
import sudoku.solver.Solver;
|
||||
import sudoku.solver.SolverStep;
|
||||
import sudoku.solver.HintHelper.Hint;
|
||||
import sudoku.structure.MultiDoku;
|
||||
|
||||
@@ -90,8 +93,9 @@ public class SudokuView extends BaseView {
|
||||
|
||||
private void startSolve(Solver solver) {
|
||||
resolveThread = new Thread(() -> {
|
||||
List<SolverStep> steps = new ArrayList<>();
|
||||
try {
|
||||
unresolved = !solver.solve(this.doku);
|
||||
unresolved = !solver.solve(this.doku, steps);
|
||||
} catch (CancellationException e) {
|
||||
System.out.println("The user is bored !");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class BacktrackingSolver implements Solver {
|
||||
for (int symbol : possibleSymbols) {
|
||||
cellToFill.setSymbolIndex(symbol);
|
||||
addStep(cellToFill, steps);
|
||||
if (this.solve(doku)) {
|
||||
if (this.solve(doku, steps)) {
|
||||
return true;
|
||||
} else {
|
||||
cellToFill.setSymbolIndex(Cell.NOSYMBOL);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class HumanSolver implements Solver {
|
||||
cellToFill.setSymbolIndex(possibleSymbols.getFirst());
|
||||
addStep(cellToFill, steps);
|
||||
|
||||
return this.solve(doku);
|
||||
return this.solve(doku, steps);
|
||||
}
|
||||
|
||||
return doku.isSolved();
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MixedSolver implements Solver {
|
||||
if (possibleSymbols.size() == 1) {
|
||||
cellToFill.setSymbolIndex(possibleSymbols.getFirst());
|
||||
addStep(cellToFill, steps);
|
||||
if (this.solve(doku)) {
|
||||
if (this.solve(doku, steps)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class MixedSolver implements Solver {
|
||||
|
||||
cellToFill.setSymbolIndex(nextSymbol);
|
||||
addStep(cellToFill, steps);
|
||||
if (this.solve(doku)) {
|
||||
if (this.solve(doku, steps)) {
|
||||
return true;
|
||||
}
|
||||
cellToFill.setSymbolIndex(Cell.NOSYMBOL);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class RandomSolver implements Solver {
|
||||
|
||||
cellToFill.setSymbolIndex(nextSymbol);
|
||||
addStep(cellToFill, steps);
|
||||
if (this.solve(doku)) {
|
||||
if (this.solve(doku, steps)) {
|
||||
return true;
|
||||
}
|
||||
cellToFill.setSymbolIndex(Cell.NOSYMBOL);
|
||||
|
||||
Reference in New Issue
Block a user