[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sudoku generator

Posted on 2006-05-14
26
Medium Priority
?
900 Views
Last Modified: 2010-04-05
I have been interested in sudoku for some time and decided to create a Sudoku game at home.
I have the ability to solve puzzles but would like the source code for the generator of those puzzles. This generator needs to have levels. Any help with source code would be appreciated
Thanx
0
Comment
Question by:eldraco
  • 9
  • 6
  • 5
  • +3
24 Comments
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16680055
After some googling, maybe this is something for you :
http://www.buchmanager-berlin.de/homepage/data/projects/sudoku_solver.zip

BEst regards,

The Mayor.
0
 

Author Comment

by:eldraco
ID: 16680074
Thank you for your quick response but this only displays one puzzle that is hardcoded.
What I require is the ability to generate puzzles at various levels of complexity.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16680167
Another link : http://www.1javastreet.com/vb/scripts/ShowCode.asp?txtCodeId=1670&lngWId=7

I was not able to open to project because of the Edit1.BevelInner-property that was missing in my Delphi-Version.
I have Delphi 5. Maybe it was developed for a later version.

Just try it out and let me know.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:eldraco
ID: 16680180
This again uses a hardcoded puzzle.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16680392
Hm, Are you sure ?
I opened the project and ignored all warnings.
I then removed 'Variant' from the uses-list
Then I compiled the application and this worked.

When I run the app, I get different puzzles everytime I click on the 'New Sudoku' button

And I can see an Randomize-FunctionCall in the code, So I would expect that the Sudoku-Logic is there to randomly generate a new puzzle.
0
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 16680400
I think this is what you want.

unfortunatley not coded in delphi, but gives everything else to build sudoko for palm PC, including i beleive how to genorate new games

http://msdn.microsoft.com/mobility/tabletpc/articles/techart/default.aspx?pull=/library/en-us/dntablet/html/tbconsudokusamplefinal.asp

David
0
 

Author Comment

by:eldraco
ID: 16680485
wimmeyvaet
     I tried that myself but all I get is  the same number in the correct places throughout the grid.
Davidbirch2.com
  Thanks for that but I would prefer the solution in Delphi.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16680614
Have you tried to click on the 'New SUDOKU'-Button ?
I get a different start-situation every time I click this button.
0
 

Author Comment

by:eldraco
ID: 16680684
Each time I press this button I get , for example, the number 3 in each 3x3 square in the correct spot e.g The number 3 in the first row of the first 3x3, the number 3 in the second row of the next 3x3 and lastly the number 3 on the bottom row of the third 3x3 etc
0
 
LVL 16

Expert Comment

by:CodedK
ID: 16680759
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16681000
Hi CodedK,

Your url links to the same application I already provided in one of my previous comments ...
0
 
LVL 16

Expert Comment

by:CodedK
ID: 16681005
Hi wimmeyvaert.
Sorry i didnt check it...
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16681170
I think I have to say sorry ....
I doublechecked all my comments, and now I see that I never provided this link....
Strange ...
I think I found this one while googling but never posted a comment about it.
So, eldraco check the link of CodedK, this was the one I was referring too...

Ther you have the 'New SUDOKU' button and this is in my opinion the functionality you are looking for ...

So, I have to say sorry and not CodedK.
0
 

Author Comment

by:eldraco
ID: 16686187
As mentioned previously. The "New Sudoku" button does not generate a sudoku it only fills a single digit in each of the 9 sets of 3x3 squares.
0
 
LVL 16

Expert Comment

by:CodedK
ID: 16688354
Eldraco you want it to create a new sudoku allready solved?
0
 

Author Comment

by:eldraco
ID: 16688413
If this is possible. I could then clear random cells to create a puzzle.
The previous link uses a hardcoded Sudoku and randomly clears cells in the grid.
0
 
LVL 16

Expert Comment

by:CodedK
ID: 16689053
:) I think this will do !!

http://download.birdiesoft.dk/Sudoku.exe
0
 

Author Comment

by:eldraco
ID: 16689245
This program solves existing sudoku puzzles but does not create a puzzle
0
 
LVL 16

Expert Comment

by:CodedK
ID: 16689713
No i thing it can.

You create a new empty game then you can write any number you want in any empty space.
Then you can click solve or brute force and it will solve it for you.
0
 

Author Comment

by:eldraco
ID: 16694502
That is correct. That means you create the Sudoku. I want the computer to create one for me.
0
 
LVL 1

Accepted Solution

by:
henrythacker earned 1000 total points
ID: 16826690
I have written a programme which you may not accept as it is quite brute forcing to generate the sudoku, but it will always generate a valid one eventually, it doesn't really take that long - some only take a matter of seconds to generate. The EXE is at http://www.zeekay.com/sudoku.zip  If this looks like what you want, let me know and will be able to release the code for it too. The puzzle generation routine seems to crash occasionally on the medium or expert settings, i can't really understand why this is... When it generates the puzzle, the puzzle is always 100% solvable - im not sure though when you turn it into an actual puzzle, whether it is always 100% possible to solve them. This bit may need tinkering with, but the bare bones are there to use. I can also put in a save/print function if you wanted to increase the point count slightly! ;) You should be fine with this as it is purely a simple TImage it draws the grid into.
0
 

Author Comment

by:eldraco
ID: 16829182
henrythacker, I have been on holidays and have only now got back.
I have tried your application and it looks good. Please release the code so that I can try it for myself
eldraco
0
 
LVL 1

Expert Comment

by:henrythacker
ID: 16834410
OK, I have uploaded it to: http://www.zeekay.com/SudokuSource.zip

I apologise for the lack of consistent formatting or commenting - I am a Computer Science student, but still the temptation is not to do it the "proper" way when you think no-one else is going to look at your code!

Everything is configurable with hard-coded values, so it should give you a very good starting point, if not a complete solution.

HTH
0
 
LVL 14

Expert Comment

by:cwwkie
ID: 17671893
henrythacker,

I have uploaded your source to https://filedb.experts-exchange.com/incoming/ee-stuff/986-SudokuSource.zip
If you don't agree, you can ask a moderator to remove it, but in that case you won't get any points for this question, because the source is part of the answer.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question