This commit is contained in:
@@ -237,31 +237,13 @@ public class SudokuFactory {
|
||||
return new MultiDoku(Arrays.asList(sudoku1, sudoku2, sudoku3, sudoku4, sudoku5));
|
||||
}
|
||||
|
||||
public static MultiDoku createBasicRectangleDokuToSolve(int width, int height, double difficulty) throws Exception {
|
||||
MultiDoku doku = createBasicEmptyRectangleSudoku(width, height);
|
||||
public static void fillDoku(MultiDoku doku, Difficulty difficulty) throws Exception {
|
||||
Solver.solveRandom(doku, random);
|
||||
int nbCellsToEmpty = (int)(difficulty*doku.getNbCells());
|
||||
int nbCellsToEmpty = (int)(difficulty.getFactor()*doku.getNbCells());
|
||||
boolean successfull = newDokuFromFilledOne(doku, nbCellsToEmpty);
|
||||
if (!successfull) {
|
||||
throw new Exception("Canno't create this doku with this difficulty");
|
||||
}
|
||||
doku.setFilledCellsImmutable();
|
||||
return doku;
|
||||
}
|
||||
|
||||
public static MultiDoku createBasicSquareDokuToSolve(int size, double difficulty) throws Exception {
|
||||
return createBasicRectangleDokuToSolve(size, size, difficulty);
|
||||
}
|
||||
|
||||
public static MultiDoku createBasicXShapedMultiDokuToSolve(int size, double difficulty) throws Exception {
|
||||
MultiDoku doku = createBasicXShapedMultidoku(size);
|
||||
Solver.solveRandom(doku, random);
|
||||
int nbCellsToEmpty = (int)(difficulty*doku.getNbCells());
|
||||
boolean successful = newDokuFromFilledOne(doku, nbCellsToEmpty);
|
||||
if (!successful) {
|
||||
throw new Exception("Cannot create this Doku with this difficulty");
|
||||
}
|
||||
doku.setFilledCellsImmutable();
|
||||
return doku;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user