Sudoku, another one

klaus

Expert
Licensed User
Longtime User
Here is my Sudoku program.

There are already 2 of them in the forum, but I did miss some functions so I wrote my own.

What the program does:
- generate grids with 4 levels of difficuties
- show the small numbers
- edit user grids (no solver yet)
- htc look
- program texts in english, french and german (italian, spanish and portuguese can be added in translating existing files and save them with I for italian, S for spanish and P for portuguese as the last character in the text file names (EX. GTextI.txt and SudokuI.txt.
- supports 240*320 and 240*400 screen sizes

Bug reports and improvement suggestions are welcome.

Have fun and Best regards.

EDIT 2010.02.06 : You must also copy the lng directory on the device in the same directory as the program.

EDIT 2010.02.07 Version 1.1 : Fixed problem with unassigned/unused variables.

EDIT 2010.02.08 Version1.2 : Fixed problem when leaving the program.

EDIT 2010.02.11 Version1.3 :
- Added solver, not the best one yet, misses solutions for difficult puzzles
- Added background coloring
- Added background color for 1 and 2 small number cadidates
- Added saving and loading of puzzles

EDIT 2010.02.19 Version 1.5:
- Added editing small numbers
- Added filtering on a small number
 

Attachments

  • Sudoku_V1_5.zip
    53.4 KB · Views: 384
Last edited:

moster67

Expert
Licensed User
Longtime User
Klaus,

I just downloaded your application. I compiled it and ran it on my HTC HD2.

When lauching it on my HTC HD2, I got some initial errors. I just said "continue" and then a I started a new game. So far it seems to work very well. There are some minor problems - for instance, when exiting the application I can't see the message in the msgbox - only Yes or No.

I will test your application better when I have some free time and get back to you soonest with a more precise report.
 

moster67

Expert
Licensed User
Longtime User
No, I didn't.

I now copied it to the device and everything is now working fine!:)

I will try it more in the next days.

Thanks for the program.


Did you copy the lng directory to the device, in the same directory as the program ?
 

dlfallen

Active Member
Licensed User
Longtime User
Hi Klaus, nice job on the Sudoku program! For some time now I have had it in mind to write my own version for exactly the reasons you wrote yours. Now I don't have to as you have come very close to what I desired. My favorite desktop version is Simple Sudoku, and your implementation is very similar.

In order to get your program to run, I had to turn off error checking. With error checking on I got numereous errors. Here is a list, in case it helps (error message is followed by the offending line of code):

Variable main.lblcofigtooltip in sub main.app_start is never used
145 lblConfigTooltip=35
146 lblConfigTooltip=1
Variable main.cole in sub main.btndispgrid_click is never used
720 cole = cRed
Variable main.g_resolu is used before it is assigned any value
1467 If g_Resolu Then Return
Variable main.g_resolu in sub main.resout is never used
1473 g_Resolu = True
Variable main.ecolonne is used before it is assigned any value
1603 Groupe = EColonne
Variable main.ecarre is used before it is assigned any value
1606 Else if k = ECarre Then
Variable main.eligne is used before it is assigned any value
1610 Else if k = ELgine Then
Variable main.ecarre is used before it is assigned any value
1615 Groupe = ECarre
Variable main.groupe is used before it is assigned any value
1647 Select Groupe
Variable main.groupe is used before it is assigned any value
1670 Select Groupe

Most of these are in the "Solve Grid" section which you do not have working yet. The first three errors (lines 145, 146, and 720) probably need fixing.

Also, when closing the program (running from desktop IDE) the IDE crashes.

This is a complex program - Lots of work! :sign0188:
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Thank's for the bug report.

Unfortunately once in the past I unselected the 'Check for unassingned / unused variables' option and forgot to select it again.

If you find that there are some functionalities missing please let me know.

New version in the first post.

Best regards.
 

dlfallen

Active Member
Licensed User
Longtime User
Klaus, your program still has a serious bug, at least on my desktop machine. The AppClose command in the following sub causes a crash regardless of exit method:

Sub frmMain_Close
AppClose
End Sub

Sub frmMain_Close is called from Sub btnExit_Click. If you replace the call to frmMain_Close with AppClose in that Sub, the problem disappears (and, of course, the Sub frmMain_Close Sub becomes unnecessary).

Notice also that if you end the program by clicking btnExit, the following code is executed:
SaveInit
Setup.SetupSave
but this code is bypassed if you terminate by clicking "X" in the upper-righthand corner. One simple fix would be to put the two save commands in the frmMain_Close Sub, with AppClose being the last line in the btnExit Sub.

As far as functionality goes, the two things I miss are
(1) filtering on pairs - that is, cells with only two candidates. Simple Sudoku does this by changing the background color of the selected cell. I'm not sure if it is worth trying to implement in your program, it is only a minor convenience. A more important function is
(2) Color tagging (or what ever you call it). There is an advanced solving method that involves the user coloring certain cells in different colors. Once in a while it is a big help in cracking a very difficult puzzle.

Neither functionality is a deal breaker, however. Your program is quite good just the way it is.

Are you pursuing the solver engine? I found some VB code that solves Sudoku puzzles. Be glad to send it to you if you could use it.

-Dave
 

klaus

Expert
Licensed User
Longtime User
Hi Dave,

Thank you for the bug report, I hadn't trouble with that but I have changed it now.

(1) filtering on pairs - that is, cells with only two candidates. Simple Sudoku does this by changing the background color of the selected cell. I'm not sure if it is worth trying to implement in your program, it is only a minor convenience. A more important function is
Should this be always or only in conjunction with the display of the small numbers? Wouldn't be that complicated.

(2) Color tagging (or what ever you call it). There is an advanced solving method that involves the user coloring certain cells in different colors. Once in a while it is a big help in cracking a very difficult puzzle.
Does this only mean to have a function allowing to change a cell's background color? Selecting a color and pointing onto a cell would change it's color ?

Are you pursuing the solver engine? I found some VB code that solves Sudoku puzzles. Be glad to send it to you if you could use it.
Yes I'm looking forward to add the solver, I would be pleased if you could send me the VB code,

Best regards.
 

dlfallen

Active Member
Licensed User
Longtime User
Hi Klaus:

Filtering on pairs does refer only to candidate pairs. When activated, any cell containing exactly two small numbers would be highlighted (cell background color would change).

Color tagging: You understand it correctly.

One functionality I overlooked is the ability to manually edit the candidates (small numbers). This can be crucial in solving difficult problems.

I'll try to send you the solver VB code in a PM.

-Dave
 

klaus

Expert
Licensed User
Longtime User
There is a new version 1.3 in the first post.
- Added solver, not the best one yet, misses solutions for difficult puzzles
- Added background coloring
- Added background color for 1 and 2 small number cadidates
- Added saving and loading of puzzles

@dlfallen.
I haven't added the editing of small numbers. Is this necessary, becaus the small numbers can be displayed automatically.
I have translated the source code of the solver, you sent me, from VB to B4PPC. Unfortunately it is nor able to find solutions for difficult grids. I will look for an other one.

Best regards.
 

dlfallen

Active Member
Licensed User
Longtime User
Sorry the solver code doesn't find difficult solutions. I thought it was a brute force approach which should solve anything.

I like the way you implemented the colors - toggling between numbers and colors.

For me, the editing of small numbers is quite useful. Your program, like all others, select candidates (small numbers) by eliminating any number already in the same row, column, or block. But there are other way of logically eliminating candidates. If I can edit your small numbers, I can reduce the set of candidates and sometimes see a result that would otherwise be obscured.

The other feature that makes solving puzzles less tedious is candidate filtering. Earlier I mentioned filtering on pairs (changing the background color of all cells with exactly two small numbers. A filter even more useful is the filtering of single numbers. For example, if I were filtering on two's then any cell with the number 2 as one of the small numbers would be highlighted. This makes it easy to spot single numbers that appear in only one row, column, or block.

I hate to keep putting forth my own preferences. I'm tempted to finish my own Sudoku program. I am sure there is zero demand for it but it is a good programming exercise and I could get it to work exactly the way I wanted. I did most of the UI a few months ago, and some of the program code. On the other hand, I don't want to compete with what you have written. It is a pretty nice program just the way it is!

-Dave
 

klaus

Expert
Licensed User
Longtime User
There is a new version V1.5 in the first post.

Added dfallen's suggestions:
- editing of small numbers
- filtering on a given small number

Bug reports and improvement suggestions are, of course, still welcome.

Enjoy and best regards.

A more sophisticated solver is still missing, but will hopefully come quite soon.
 
Top