IonicWind Software

IWBasic => The Roundtable => Topic started by: TonyMUK on January 13, 2009, 01:38:17 AM

Title: Sudoku
Post by: TonyMUK on January 13, 2009, 01:38:17 AM
This is my attempt at a sudoku program that does not rely on pre-generated grids. The grid is generated randomly every time. Please excuse my sloppy programming but I haven't got round to tidying it up yet.
Title: Re: Sudoku
Post by: mrainey on January 13, 2009, 08:00:05 AM
Nice one.   :)
Title: Re: Sudoku
Post by: TonyMUK on January 13, 2009, 08:49:30 AM
Thanks. The greatest challenge was creating a workable grid in a reasonable time. My first attempts were take over 15 minutes.
Title: Re: Sudoku
Post by: RG on January 13, 2009, 08:27:27 PM
the grid generation is very fast - good job

are you going to put in different degrees of difficulty? didn't know what levels these are
Title: Re: Sudoku
Post by: TonyMUK on January 14, 2009, 08:09:55 AM
Thanks. I tried to make it as quick as possible while still been a fully solvable grid. I will get round to different levels of difficulty as well as some other features I want to add.
Title: Re: Sudoku
Post by: TonyMUK on January 15, 2009, 04:55:25 AM
Updated.
Title: Re: Sudoku
Post by: TonyMUK on January 16, 2009, 07:16:59 AM
Final update unless anyone has anything they would like to see added.
Title: Re: Sudoku
Post by: fasecero on January 16, 2009, 09:57:50 AM
Nice and fun, good work and thx for sharing!!   :)
Title: Re: Sudoku
Post by: TonyMUK on January 17, 2009, 01:06:48 AM
Can't see the point in writing these things if I wasn't going to share them. I get paid for programming in my professional life so anything I write for fun I share.
Title: Re: Sudoku
Post by: Haim on January 17, 2009, 03:51:54 AM
Thanks for sharing this,

Haim
Title: Re: Sudoku
Post by: RG on January 17, 2009, 09:36:32 AM
I play Sudoku so I have two suggestions to make this playable for me:

1. Right now the only number input seems to be clicking multiple times on a square. Easy for numbers 1 & 2, hard for 8 and 9. There also seems to be a slight delay in reading the next click so sometimes it takes 11-12 clicks to get to number 9. Any way to allow both clicking input or typing in the number directly?

2. I liked the buttons on the first version as they were easily accessible. Can you have both menu and buttons for some of the common commands? The ones I would use most would be new grid and check.

I do like the overall simplicity and speed of the game.

Rich
Title: Re: Sudoku
Post by: TonyMUK on January 17, 2009, 11:17:41 AM
Right click on a square and it brings up the numbers 1 to 9 with 0 to erase. Just click on the number you want to place it in the square.

I took the buttons off because I thought the menus looked better. I'll put them back on if that's what you prefer. Will update sometime in next two days and post new version.
Title: Re: Sudoku
Post by: RG on January 17, 2009, 03:43:46 PM
Oh, that's a big help (right clicking) - just what I needed.
Title: Re: Sudoku
Post by: TonyMUK on January 23, 2009, 09:28:52 AM
Latest and final version.
Title: Re: Sudoku
Post by: mrainey on January 23, 2009, 09:53:37 AM
QuoteLatest and final version.


There's no such thing as a final version.   :D
Title: Re: Sudoku
Post by: TonyMUK on January 23, 2009, 10:43:57 AM
True, but there is a version I'm not going to be changing any more.  :)
Title: Re: Sudoku
Post by: Brian on January 23, 2009, 11:38:25 AM
Good stuff, Tony - I managed to complete an "easy" Sudoku without any problems

Brian
Title: Re: Sudoku
Post by: TonyMUK on January 23, 2009, 11:57:04 AM
Glad you like it.  ;D
Title: Re: Sudoku
Post by: Brian on January 24, 2009, 09:07:11 AM
Tony,

There is a slight problem with the Double Size:

If you select New Grid, and then Double Size, the grid is OK

If you close the program, and restart, then select Double Size before
New Grid, the grid has double numbers, slightly offset

Brian
Title: Re: Sudoku
Post by: Johnny on January 24, 2009, 08:35:39 PM
Hi,

Nice program by the way!   :)

I noticed also the strange double printing, checked the code, and changed five lines to make it printing cleaner.

Modify lines 222, 274, 321, 391, and 448, as follows:
Move w1,m*20*Scale+26*Scale,n*20*Scale+22*Scale
(Watch out, line 274 uses "a" and "b" in stead of "m" and "n", keep the original variables!)

One other thing, sometimes I think I solved the puzzle, but the program refuses my solution, although I think it is solved correctly???   :-[
(Atached image) Well, I could be wrong though, I never solved a puzzle like this before... :-[

Kind regards,
Johnny
Title: Re: Sudoku
Post by: celphick on January 25, 2009, 12:31:22 AM
Johnny
Your solution is correct.
I found an example that had 7 correct solutions.
I suspect that the answer is checked against the generated puzzle, not against the solutions own integrity.
Don't quibble about a nicely developing program that its author is revealing as it is developed.
Regards Colin.
Title: Re: Sudoku
Post by: TonyMUK on January 25, 2009, 01:17:38 AM
It does indeed check against the solution it has generated. I have not gone as far as checking if there are other solutions available.

Thanks for the fix for the double printing.
Title: Re: Sudoku
Post by: Johnny on January 25, 2009, 05:38:55 AM
Hi,

Colin, I don't know where you got the idea that I'm criticizing the program, I like it, and that was also what I stated at the start!
The only thing is, since I never tried to solve a puzzle like that (I even stated that in my first message), I wasn't sure that I really solved it the correct way, or maybe overlooked something, or maybe just something like several solutions possible (Tony's answer cleared it up, that is was just this last possibility), hence my (rather embarest!) question.
Remember that not everybody is as good in games as you might be Colin, I barely have time for that in my life, hence my ignorance.
So in the future, please try not to twist somebody's words into an evil remark...
I rather like to help here or there "a little bit" than to "quibble"!

And to Tony, thanks for sharing your work!

Kind regards,
Johnny
Title: Re: Sudoku
Post by: TonyMUK on January 25, 2009, 07:17:53 AM
I didn't take it as criticism. Any comments are welcome when they are constructive.

Cheers Johnny.
Title: Re: Sudoku
Post by: TonyMUK on January 29, 2009, 06:28:10 AM
Said I wouldn't but have updated again. Now allows other solutions as well as the one it originally generates.
Title: Re: Sudoku
Post by: Johnny on January 29, 2009, 05:13:54 PM
Tony, I didn't expected you to add this feature you know, I was only a bit confused about how it worked...
But I really appreciate it that you added this feature, so thank you a lot in the name of all the puzzlers here!   :)

Cheers,
Johnny
Title: Re: Sudoku
Post by: RG on January 29, 2009, 09:00:08 PM
works great  :)

I've learned never to say "last version" as I always find something I need to fix

thanks for sharing
Title: Re: Sudoku
Post by: TonyMUK on January 30, 2009, 02:09:52 AM
Quote from: Johnny on January 29, 2009, 05:13:54 PM
Tony, I didn't expected you to add this feature you know, I was only a bit confused about how it worked...
But I really appreciate it that you added this feature, so thank you a lot in the name of all the puzzlers here!   :)

Cheers,
Johnny

My pleasure. Enjoyed the challenge. This is by far the largest EBasic program I have written so far. Just glad everyone likes it.