dachev / sudoku

Sudoku generator and solver for node.js
146 stars 44 forks source link

explain ratepuzzle function please? #7

Closed rachidelaid closed 4 years ago

rachidelaid commented 4 years ago

the ratepuzzle function returns a random number every time, and I don't understand that number. I want to select a specific difficulty but I don't know the range. can you please help me with that?

dachev commented 4 years ago

@rachidelaid ratepuzzle runs the solver N times and then it calculates the average difficulty based on individual runs. Increasing the number of samples, in the second argument, should help the numbers converge and produce a more stable estimate.

rachidelaid commented 4 years ago

sorry I still didn't get it yet. does this mean the higher the number it returns the difficult it is?

for example: sudoku.ratepuzzle(puzzle, 3); -if it is less then 1 it's easy. -between 1 and 2 medium. -bigger then 2 is hard.

can you please give some more details. thanks

dachev commented 4 years ago

I don't remember the semantic meaning of the difficulty coefficient but I don't think it has an upper bound. You would have to define the difficulty brackets empirically for yourself.

dachev commented 4 years ago

To add to this, rating is based on the amount of guessing (or thinking ahead more than one move) that you may have to do. See the Rating Puzzles section on this page: http://davidbau.com/archives/2006/09/04/sudoku_generator.html