Author |
Message |
Forumer
|
Posted: Fri May 07, 2010 1:22 pm Post subject: Java Sudoku Generator |
|
|
hi, i need help generating sudoku in java, any help will be very much appreciated and examples will be very very helpful |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
|
|
|
|
SNIPERDUDE
|
Posted: Fri May 07, 2010 3:49 pm Post subject: RE:Java Sudoku Generator |
|
|
each section contains numbers 1-9, each row contains numbers 1-9, no duplicates.
Try creating an engine that will make a complete Sudoku puzzle, then have it leave only a handful of tiles visible (a number varied by difficulty level), evenly distributed throughout each section (you don't want all the visible tiles that one starts off with in one corner of the puzzle).
Just some ideas to work with. |
|
|
|
|
|
OneOffDriveByPoster
|
Posted: Fri May 07, 2010 3:59 pm Post subject: Re: RE:Java Sudoku Generator |
|
|
Generating a puzzle with a unique solution is a possible requirement. |
|
|
|
|
|
USEC_OFFICER
|
Posted: Fri May 07, 2010 8:11 pm Post subject: RE:Java Sudoku Generator |
|
|
Just like to point out that the computer will then have to reconize when the solution the player comes up with is different from its own. That's the problem with randomly generated Sudokus. |
|
|
|
|
|
Tony
|
Posted: Fri May 07, 2010 8:41 pm Post subject: RE:Java Sudoku Generator |
|
|
Sudoku puzzles typically come with unique solutions, which might not be the case if enough pieces are taken away. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Forumer
|
Posted: Tue May 11, 2010 6:44 am Post subject: RE:Java Sudoku Generator |
|
|
i want to generate the whole completely puzzle, then have the program use a random sudoku pattern, while saving the original generated puzzle to give player hints |
|
|
|
|
|
Unnamed.t
|
Posted: Fri May 28, 2010 2:50 pm Post subject: Re: Java Sudoku Generator |
|
|
K I understand what you need to do Forumer because I have made a Sudoku program myself as well. For the AI of generating puzzles. One of the methods is actually going to check values that will fit into the 9x9 grid. A hint on making this is to have a boolean method that has a two dimensional array ([9][9]) as its parameter. This method should be able to come up with possible solution for a puzzle. The method should use a type of recursion that will continuously return false until a value fits (true). It will use four for loops (1 to 9). 2 for loops to check and compare with the other two for loops.
The other method should integrate the logic of the first method to generate a puzzle. Using a random int generator command use the variable with the random int to be loaded into one spot of your 2-d array. Run the other method in this method to start filling up your puzzle. As long is you are running a random int from 1 to 9 and placing it in one spot of the array you should be able to generate 729 (9*81) different sudoku puzzles.
Depending on your programming experience and how good you are with java, you can use a nasty if structure that can actually allow you to generate 13 122 (729*18) sudoku puzzles.
In the end you just have to think A LOT to actually figure out how to do this stuff, but follow this guide and you can probably do it. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|