This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package gui.menu;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CancellationException;
|
||||
|
||||
import gui.SudokuRenderer;
|
||||
import imgui.ImGui;
|
||||
import imgui.ImGuiStyle;
|
||||
import sudoku.io.SudokuSerializer;
|
||||
import sudoku.solver.BacktrackingSolver;
|
||||
import sudoku.solver.HumanSolver;
|
||||
import sudoku.solver.MixedSolver;
|
||||
import sudoku.solver.Solver;
|
||||
import sudoku.structure.MultiDoku;
|
||||
|
||||
@@ -66,41 +68,29 @@ public class SudokuView extends BaseView {
|
||||
stopResolve();
|
||||
}
|
||||
|
||||
private void startSolve(Solver solver) {
|
||||
resolveThread = new Thread(() -> {
|
||||
try {
|
||||
solver.solve(this.doku);
|
||||
} catch (CancellationException e) {
|
||||
System.out.println("The user is bored !");
|
||||
}
|
||||
stopResolve();
|
||||
});
|
||||
}
|
||||
|
||||
private void renderSolvePopup() {
|
||||
if (ImGui.beginPopup("solve")) {
|
||||
if (ImGui.button("Résoudre avec backtrace")) {
|
||||
resolveThread = new Thread(() -> {
|
||||
try {
|
||||
Random rand = new Random();
|
||||
Solver.randomSolve(doku, rand);
|
||||
} catch (CancellationException e) {
|
||||
System.out.println("The user is bored !");
|
||||
}
|
||||
stopResolve();
|
||||
});
|
||||
startSolve(new BacktrackingSolver());
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
if (ImGui.button("Résoudre avec déduction")) {
|
||||
resolveThread = new Thread(() -> {
|
||||
try {
|
||||
Solver.humanSolve(doku);
|
||||
} catch (CancellationException e) {
|
||||
System.out.println("The user is bored !");
|
||||
}
|
||||
stopResolve();
|
||||
});
|
||||
startSolve(new HumanSolver());
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
if (ImGui.button("Résoudre avec déduction et backtrace")) {
|
||||
resolveThread = new Thread(() -> {
|
||||
try {
|
||||
Random rand = new Random();
|
||||
Solver.mixedSolve(doku, rand);
|
||||
} catch (CancellationException e) {
|
||||
System.out.println("The user is bored !");
|
||||
}
|
||||
stopResolve();
|
||||
});
|
||||
startSolve(new MixedSolver());
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
ImGui.endPopup();
|
||||
|
||||
Reference in New Issue
Block a user