This commit is contained in:
@@ -42,6 +42,10 @@ public interface Solver {
|
||||
cellToFill.setSymbolIndex(symbol);
|
||||
if (solve(doku)) {
|
||||
result++;
|
||||
if (result > 1) {
|
||||
doku.getStateManager().popState();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
doku.getStateManager().popState();
|
||||
}
|
||||
|
||||
@@ -142,21 +142,14 @@ public class SudokuFactory {
|
||||
|
||||
List<Cell> cellsThatCanBeEmptied = doku.getFilledCells();
|
||||
|
||||
while (!cellsThatCanBeEmptied.isEmpty()) {
|
||||
int index = random.nextInt(cellsThatCanBeEmptied.size());
|
||||
Cell cellToEmpty = cellsThatCanBeEmptied.get(index);
|
||||
int index = random.nextInt(cellsThatCanBeEmptied.size());
|
||||
Cell cellToEmpty = cellsThatCanBeEmptied.get(index);
|
||||
|
||||
int oldSymbol = cellToEmpty.empty();
|
||||
cellToEmpty.empty();
|
||||
|
||||
int nbDokuSultions = solver.countSolution(doku);
|
||||
if (nbDokuSultions == 1) {
|
||||
if (newDokuFromFilledOne(doku, --nbCellsToEmpty, solver)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
cellToEmpty.setSymbolIndex(oldSymbol);
|
||||
cellsThatCanBeEmptied.remove(cellToEmpty);
|
||||
int nbDokuSultions = solver.countSolution(doku);
|
||||
if (nbDokuSultions == 1) {
|
||||
return newDokuFromFilledOne(doku, --nbCellsToEmpty, solver);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -243,7 +236,7 @@ public class SudokuFactory {
|
||||
|
||||
/*
|
||||
* 2 3
|
||||
* 1
|
||||
* 1
|
||||
* 4 5
|
||||
*/
|
||||
|
||||
@@ -276,7 +269,7 @@ public class SudokuFactory {
|
||||
|
||||
/*
|
||||
* 2 3
|
||||
* 1
|
||||
* 1
|
||||
* 4 5
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user