feat : solver random
Some checks are pending
Linux arm64 / Build (push) Waiting to run

This commit is contained in:
Melvyn
2025-01-27 14:48:28 +01:00
parent 3bb610b9c2
commit 80239274d7
6 changed files with 74 additions and 51 deletions

View File

@@ -3,6 +3,7 @@ package gui.menu;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CancellationException;
import gui.ColorGenerator;
@@ -12,7 +13,7 @@ import imgui.ImVec2;
import imgui.ImVec4;
import imgui.flag.ImGuiCol;
import imgui.flag.ImGuiStyleVar;
import sudoku.solver.StupidSolver;
import sudoku.solver.Solver;
import sudoku.structure.Block;
import sudoku.structure.Cell;
import sudoku.structure.MultiDoku;
@@ -98,19 +99,18 @@ public class SudokuView extends BaseView {
ImGui.beginDisabled();
if (ImGui.button("Résoudre")) {
resolveThread = new Thread(new Runnable() {
@Override
public void run() {
try {
doku.getSubGrid(0).clear();
StupidSolver.solve(doku);
Thread.sleep(200);
} catch (CancellationException | InterruptedException e) {
System.out.println("The user is bored !");
}
stopResolve();
}
});
resolveThread = new Thread(() -> {
try {
Random rand = new Random();
doku.getSubGrid(0).clear();
Solver.solveRandom(doku, rand);
Thread.sleep(200);
} catch (CancellationException | InterruptedException e) {
System.out.println("The user is bored !");
}
stopResolve();
});
}
boolean wantsToStop = false;
if (resolveThread != null && resolveThread.isAlive()){