From the looks of the code, puzzle generation is dependent on a good solve
method:
[GNUDoku.C]
void GNUDoku::generatePuzzle(float const difficulty, int const seed){
...
Sudoku::solve(stack, top, &flag_data, visited);
...
}
Glancing at the solve algorithm, it looks like the solve method in its current
form will not give up straight away if it cannot solve a puzzle from a specific
step. In this case it will carry out a series of trials (I think up to 10) until
a working solution is found. The advantage of such a technique is that it allows
the program to solve puzzles that are beyond the ability of its logical
reasoning. The disadvantage is that the puzzle generation algorithm is not able
to determine whether or not a puzzle will have multiple solutions.
[sudoku-solve.C]
bool Solve(Board& board, std::vector<move>& moves){
...
/* once the forced moves have been exhausted, we need to make a 'likely'
* move. Such moves are based on trial and error, like random moves, but
* more directed, as they will go for the boxes with the fewest possible
* mistakes. */
...
}
I would expect that fixing this bug in the code would, in the simplest case,
require the removal of this trial-and-error algorithm. While doing that would
(probably) result in unambiguous puzzles, it would also make the generated
puzzles a lot simpler.
Hope this helps,
David
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]