feat: show resolve logs
All checks were successful
Linux arm64 / Build (push) Successful in 40s

This commit is contained in:
2025-02-02 00:04:52 +01:00
parent 129c3ef0b2
commit f3bbfd9e6c
4 changed files with 40 additions and 43 deletions

View File

@@ -227,7 +227,7 @@ public class ConsoleInterface {
saveMultiDoku(doku);
break;
case "solution":
solve(doku);
solve(doku, listSymbols, width, height);
break;
case "exit":
exit();
@@ -238,21 +238,52 @@ public class ConsoleInterface {
}
}
private void solve(MultiDoku doku){
System.out.println("Pick a solver to use : random ('random', default), human ('human') or mixed solver ('mixed').");
private void applyStep(SolverStep step) {
step.getCell().setSymbolIndex(step.getNewValue());
}
private boolean showStep(MultiDoku doku, List<String> listSymbols, int width, int height, SolverStep step) {
System.out.println("Here is the step : \n");
showMultidoku(doku, listSymbols, width, height);
applyStep(step);
System.out.println("\nTurns into :\n");
showMultidoku(doku, listSymbols, width, height);
System.out.println("Do you want to see the next step ? (y/n, default n)");
return reader.next().equals("y");
}
private void showSolveSteps(MultiDoku doku, List<String> listSymbols, int width, int height, List<SolverStep> steps) {
System.out.println("Would you like to see the steps of the solver ? (y/n, default n)");
doku.getStateManager().popState();
switch (reader.next()) {
case "human":
new HumanSolver().solve(doku);
break;
case "mixed":
new MixedSolver().solve(doku);
case "y":
int stepCount = 0;
while(stepCount < steps.size() && showStep(doku, listSymbols, width, height, steps.get(stepCount))){stepCount++;}
break;
default:
new RandomSolver().solve(doku);
break;
}
}
private void solve(MultiDoku doku, List<String> listSymbols, int width, int height){
System.out.println("Pick a solver to use : random ('random', default), human ('human') or mixed solver ('mixed').");
List<SolverStep> steps = new ArrayList<>();
doku.getStateManager().pushState();
switch (reader.next()) {
case "human":
new HumanSolver().solve(doku, steps);
break;
case "mixed":
new MixedSolver().solve(doku, steps);
break;
default:
new RandomSolver().solve(doku, steps);
break;
}
showSolveSteps(doku, listSymbols, width, height, steps);
}
private void play(MultiDoku doku, List<String> listSymbols, int width, int height) {
int x, y;
RenderableMultidoku rdoku = RenderableMultidoku.fromMultidoku(doku);