문제

My current plan is to generate an random initial board and randomly remove numbers. However, is there a way to make sure my puzzles are within a certain difficulty, like 'normal', without accidentally removing numbers so that the puzzle is too easy or hard?

Furthermore, do I have to include a simulated board solver to determine if a puzzle becomes unsolvable or too easy?

도움이 되었습니까?

해결책 3

After doing some research, it turns out there's no easy way to accurately determine human difficulty, as described here. The easiest way is to count the number of blank squares.

However, some patterns are easier to find than others, such as if squares can be solved independently from others, or if there's only one solution available for a square. Difficulty and solving time require some statistical analysis of quite a few different patterns, and how many opportunities there are for strategies to be used.

다른 팁

Difficulty typically refers to the amount of unnumbered spaces available at the start from what i've seen in sudoku. Why don't you start with a fully solved randomly created board, then from there start removing numbers, and starting from the most solved row/col/box to the least solved. Then you could have a variable to check to see if the removed spaces has reached the limit.

I would suggest basically starting with a solved world, a predecessor function that finds which row/col/box is the most solved i.e. has the most available correct numbers. And you can determine its meaning across the 3 different areas as you wish. Then a successor function that removes a space from the current row/col/box as well as updates each of those to reflect the update. Like say you have an int array for rows 0-8, another for cols 0-8, and box 0-8. Rows go from 0->8 from top to bot, cols 0->8 left to right, boxes 0->8 to the right then down a row and repeat. Start one off each with 9's in the indices. Each time you remove a number, say you remove (row#,col#). Then put row[row#]--, col[col#]-- and box[(row#/3)*3 + col#/3]--. Then increment a removed number counter and check that against your difficulty which is defied by total possible removed numbers. *Notice the (row#/3) is integer division.

Randomly removing numbers will not guarantee there is ONE solution. This means it's unsolvable because SuDoKu in principle has only one solution per puzzle. Antyhing else, and we are thrown into a guess-and-check improv game that vaguely resembles the original. I definitely advise researching the puzzle you are trying to simulate and how to generate puzzles.

This question is a duplicate of How to generate Sudoku boards with unique solutions

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top