feat: select solve algorithm
All checks were successful
Linux arm64 / Build (push) Successful in 25m12s
All checks were successful
Linux arm64 / Build (push) Successful in 25m12s
This commit is contained in:
@@ -66,34 +66,64 @@ public class SudokuView extends BaseView {
|
|||||||
stopResolve();
|
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();
|
||||||
|
});
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
ImGui.closeCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui.endPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void renderSolveButton() {
|
private void renderSolveButton() {
|
||||||
if (resolveThread != null)
|
if (resolveThread != null)
|
||||||
ImGui.beginDisabled();
|
ImGui.beginDisabled();
|
||||||
|
|
||||||
boolean beginSolve = false;
|
if (!this.resolved && centeredButton("Résoudre")) {
|
||||||
|
// beginSolve = true;
|
||||||
if (!resolved && centeredButton("Résoudre")) {
|
ImGui.openPopup("solve");
|
||||||
beginSolve = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolveThread != null)
|
if (resolveThread != null)
|
||||||
ImGui.endDisabled();
|
ImGui.endDisabled();
|
||||||
|
|
||||||
if (beginSolve) {
|
if (this.resolved) {
|
||||||
resolveThread = new Thread(() -> {
|
|
||||||
try {
|
|
||||||
Random rand = new Random();
|
|
||||||
Solver.randomSolve(doku, rand);
|
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (CancellationException | InterruptedException e) {
|
|
||||||
System.out.println("The user is bored !");
|
|
||||||
}
|
|
||||||
stopResolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resolved) {
|
|
||||||
ImGui.text("Bravo !");
|
ImGui.text("Bravo !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderSolvePopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderSaveButton() {
|
private void renderSaveButton() {
|
||||||
|
|||||||
Reference in New Issue
Block a user