paperlined.org
games > puzzles > sudoku
document updated 19 years ago, on Sep 28, 2005
1. Generate a full "final solution" map first

    1.0. start with a completely clear board
    1.1. check with board solver, and fill in any cells that should obviously have only one value filled in
    1.2. choose a random cell
    1.4. choose one of the remaining values at random
    1.5. check for any board-wide errors.  if errors found, go to step 1.0
    1.6. check if board is completely filled.  if not, go to step 1.1


2. Clear any derivable cells

    2.0. Put all cells in a list
    2.1. Scramble the order of the list
    2.2. Clear the cell indicated by the top of the list
    2.3. Use a rule-based (non-brute-force) solver to solve the puzzle
            (if doing an "easy" or "medium" puzzle, cause the solver to use less complicated rules to solve the puzzle)
    2.4. If the puzzle could not be solved, fill the cell with its original number
    2.5. Remove the top item from the list
    2.6. If list is not empty, go to step 2.2
    

3. Force guesses

    3.0. If generating an "easy" or "medium" puzzle, skip to the end, the puzzle is finished
    3.1. ??

    [at this point, if a human knows all the rules used in the solver, they can solve the Sudoku
    puzzle without having to make any guesses whatsoever.  Truly difficult puzzles require one (or
    possibly more, if you're feeling really sadistic) guesses.  The problem is that, at this point,
    it's very easy for the generator to make changes that will cause the puzzle to have multiple
    solutions]