java - Sudoku logic solver -
in response locking of lastly question here due lack of info seek explain farther eliminate confusion.
ok first left background info on i'm doing. started on personal project of making sudoku game larn object oriented programming, arraylists, algorithms, model/control/design layer , expanding knowledge programming. have come far way in making game , nearing completion have nail smaller problem need help solve.
i nail problem when generated 3 sudokus, 1 easy, 1 medium , 1 hard. easy , medium difficulty sudokus solvable hard sudoku unsolvable.
how works: first have algorithm using random number generation , validation generate valid sudoku board, pass through algorithm goes through numbers on 9x9 board , removes them on percent chance, percent chance specified when calling method, illustration 50% chance of removing number easy , 65% chance hard.
my issue: ok issue generated sudoku @ "hard" difficulty , found unsolvable. right have no validation method check if puzzle solvable in way, long story short chance if solvable.
what need: need algorithm or method validate if puzzle solvable cause right have random chance of beingness solvable due random number removal chance. should not done using brute force(backtracking) instead should @ puzzle , take decisions on numbers go where, , solve it. way can verify not if has single solve if , can solve it.
a little graphical view of variables , how classes connected:
a visual representation of how sudoku structured using above example:
the 1 to9 numbers in sudoku cells 1 9.
if need more detailed info on programme please tell me , add together form, tried maintain short , simple possible while still trying cover relevant issue.
i effort reply questions asked either explicitly or implicitly:
"first have algorithm using random number generation , validation generate valid sudoku board"
if algorithm generate valid sudoku board, should hence solvable. if not mean solvable please elaborate.
"i need algorithm or method validate if puzzle solvable cause right have random chance of beingness solvable due random number removal chance."
any algorithm solves sudoku validate indeed solvable. number removal might create game harder solve , increment number of valid solutions, thereby making invalid (see tactful comment made serge ballesta). mention that: "sudoku puzzles classified easy, medium or hard puzzles having more starting clues not easier solve. quantifying difficulty mathematically hard.". see mathematics of sudoku leads "richter scale" of puzzle hardness
"this should not done using brute force(backtracking) instead should @ puzzle , take decisions on numbers go where, , solve it."
you asking algorithm emulates human behavior , thinking in solving problem. not think feasible request , fall research area of artificial intelligence. train of thought followed human beings solve puzzles such sudoku differ person person. beginners might follow methods similar depth first search backtracking. when dealing hard problems not efficient method human beings. in games such chess, not sustainable method. experts have tendency recognize patterns having global view of board. quite similar process followed expert sudoku human players. see how experts recall chess positions
java algorithm sudoku
No comments:
Post a Comment