Closed steve3424 closed 4 years ago
I see some improvements:
Just some clarifications:
I think that show an error message is better because the puzzles can be imported from a file and in these cases if the imported file has errors the solver seems do nothing. What do you think?
It depends, are the imported files originally created in the app? If not, where do the puzzles from the files come from?
Yes, puzzles can be generated in other apps. Is a standard XML format implemented in first instance by GNOME team.
Sample:
<?xml version="1.0" encoding="UTF-8"?>
<opensudoku>
<name>easy generated at 2019-10-01</name>
<author>ogarcia</author>
<description></description>
<comment></comment>
<created>2019-10-01</created>
<source>opensudoku</source>
<level>easy</level>
<sourceURL>http://opensudoku.moire.org/</sourceURL>
<game data="800400692429050070600900040000500060000030500006007000910305726250060801300020450" />
</opensudoku>
Is the puzzle in one line, the zeroes are the empty fields. For the sample of above the board is:
800 400 692
429 050 070
600 900 040
000 500 060
000 030 500
006 007 000
910 305 726
250 060 801
300 020 450
Unless there is a convenient way to check if these puzzles are solvable and flag them before they are imported, it would make sense for me to put a dialog in case these puzzles are not solvable. I will put that back in.
I also think it would be useful to check puzzles that are created in this app before they are saved, what do you think?
Now it checks whether or not the puzzle is solvable before giving hints and before completely solving the puzzle
I also think it would be useful to check puzzles that are created in this app before they are saved, what do you think?
That is a great idea. But I think even if the puzzle has not solution, it should permit to save it but warning to user: This puzzle has no solution. Are you sure you want save it?
Yeah that is a good idea. I will work on adding that.
I'll merge this PR to upload a new release with the import fix
I made 2 main changes:
I modified the solver so it solves the game from the original state, ignoring user inputs. This allows it to always solve the puzzle and fill in the solution regardless of any mistakes on the board, removing the need for the ambiguous message saying there is a mistake somewhere in the puzzle.
I added the hint feature. I made it slightly different from what we discussed. It simply fills in the correct value of the selected cell no matter what the state of the board is or how many mistakes there are. If the correct value is already in, the user will see nothing happen. I could add a message in this case or in others. Let me know if you'd want me to do that.
The hint feature as it is assumes 2 things to work: