Hi Guys,
Since i am new to this forum, maybe a small introduction: i've only started doing sudokus since a few months ago. My girlfriend was doing them for quite some time already, and i used to laugh with her "sudoku-addiction". At some point i wanted to do another hobby-project (i am a programmer), and since she used an app which requires a periodic payment for new puzzles, i decided to write my own sudoku app.
Generating some sudoku puzzles ... how hard can it be, right?
Since then, i have picked up the sudoku addiction also. I am not as fast as my girlfriend yet, but i need to have my daily sudoku
And now the actual question i have: to be able to generate puzzles, i have up until now:
- a bruteforce way of generating complete solutions
- a bruteforce way to check if a puzzle has a single solution
- a solver that implements: naked/hidden singles, locked candidates and subsets. I have noticed that with only these techniques, i can already solve the majority of sudokus that most websites/apps generate. Next on the list to implement is x-wing and coloring.
I have also started on the generation of puzzles, and that works in the following way:
1: start from a full solution
2: randomly select a symmetric pair from the solution to remove (i read somewhere that puzzles are ideally symmetrical)
3: check if the puzzle can be solved, and if only one solution is possible
4: rate difficulty, and if difficulty was higher than any previously generated puzzle, store it as the most difficult puzzle
5: repeat from step 2
The actual code is more complex, because i actually start with 10 random pairs that i test in parallel, and at every step in the process i try 10 different combinations. So i am brute-force-searching many random combinations.
The effect of this is that i can easily find puzzles that involve singles and locked candidates, but my puzzles never require subsets. Which is quite odd. is there any trick or technique to use to generate more difficult puzzles? I would actually prefer to write a non-brute-force generator, but i wouldnt know where to start to be honest.