Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve level generation and classification of difficulty rating. #130

Open
coderPaddyS opened this issue Jan 8, 2025 · 0 comments
Open

Comments

@coderPaddyS
Copy link
Contributor

coderPaddyS commented Jan 8, 2025

The Privacy Friendly Sudoku app generates all sudokus locally on the device without delivering some pre-computed. So any sudoku you play had to be generated before, disregarding the daily sudoku.
This happens in the GeneratorService, a service being started if there are not enough sudokus already available (3 for each size and difficulty configuration) on app launch or on press of the new game button.
In theory this is absolutely fine and improves the user experience as new levels should be always available whilst always having different sudokus.

A new sudoku (for a given difficulty and size) is generated by first randomly placing numbers in the sudoku. If the sudoku is then solvable, this means a sudoku solver, in this case this solver by QQWing, it is assigned a difficulty rating by looking at the moves the solver did.
Such moves include guesses, pairs/triples either hidden or naked, ..., the normal sudoku "tricks" we know. The current classification happens here.

This works fine for sudokus of size 6x6 and 9x9, it sometimes took a while as all difficulties had to be generated 3 times for 6x6 before moving on to 9x9 and then 12x12. As 6x6 are pretty easy, it is hard to generate one where one has to guess to solve it, marking it as challenge difficulty. This leads to more than 100 easy levels being generated for 6x6 for one challenge one being generated.
But it works good enough for 6x6, pretty good for 9x9 as it is easier to generate a sudoku containing guesses.
However, this does not work for 16x16. It is faaaaar more likely to generate a 16x16 with guesses or at least any of the hard requirements then any medium or easy one. I'd say easy is not even plausible getting generated.
In addition, the generation of a random board config for 16x16 takes far more time then 9x9 or 6x6, sometimes needing multiple minutes which paired with the difficulty rating is even worse.

To fix this two things have to happen:
A) improve the difficulty classification:

  • Make it dependable on the selected game size
  • Perhaps attach a minimum number needed to be generated per size and difficulty to improve the rating distribution

B) improve the time the solver needs to solve the sudoku. Perhaps this is already good but lacks due to the generation, but I don't think so. This possibly needs another solver being used, e.g. this one by the ieee. The solver however needs to solve the sudoku like a normal human would, a backtracking or SAT-Solver is not helpful.

Currently it does not look like we have the time and resources to improve on this, so if your experienced in sudoku and coding and like to take this on, feel free to reach out or even directly creating a fork and PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant