RingsWorld.com RingsWorld.com [Have a Blog? Submit It!new] [Create your Site-Ring Community]

Sudoku - Solver Logic for sudoku mobile game

:(: Discussions around the Sudoku Puzzle Game :):
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat Mar 20, 2010 7:46 am
All times are GMT
Board.RingsWorld.com » Games » Sudoku
Solver Logic for sudoku mobile game
Moderators:  JBL
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
RSS Feed Add to My MSN Add to My Yahoo! Add to Google
Global Discussions
Author Message
CodeTiger



Joined: 18 May 2006
Posts: 3
Location: chennai
PostPosted: Thu May 18, 2006 1:43 pm    Post subject: Note Solver Logic for sudoku mobile game
Subject description: Solver Logic for sudoku mobile game developer
Reply with quote

Solver Logic for sudoku mobile game developer

Writing Sudoku solver is not a great task, but when it comes to writing it for a mobile phone it is really hard to choose which algorithm to use. We were in a bad situation to decide whether to write 1000s of lines and reduce the CPU power conception, or to write the most compact code. Considering a mobile phone which commonly has just 100 -200 MHz CPU and 100 kb memory, we finally decided to code in hardest way to solve sudoku which most programmers do not prefer. “Solving Sudoku by logic”, it is very similar how a human thinks when solving sudoku. We have implemented 4 methods to solve any hard puzzle. Finally we decided to start this forum to share how we made it.

Prepare the Possibility grid: first step we have to do is create possibility grid of 9x9x9 array for Booleans which represents the possible no’s that can occur in each cell. The [0][0][0] Boolean represents the possibility of occurrence of number 1 in the cell[0][0]. This possibility grid can be generated with some simple steps. Fill all cells with all Booleans, true. Now for each value in the puzzle, remove the other possible Booleans in the corresponding cell in the possibility grid, i.e. the only possibility should be the no in the possibility grid.

Step 1: Now see each row if there is a particular number which occurs only once. Then the only possibility for that number to occur in the row is that cell. So you can remove the possibilities of the occurrence of this number the other columns. Do this column wise and each block (3x3)

Check if all the cells have only one possible value then you have successfully solved the puzzle. If not you will have to implement the next method.

Step 2: Now you have a better possibility grid. See if a particular row in the possibility grid has a number occurring only in a particular block. Then remove the possibility of that number in the other cells of the block. Repeat this for columns. See in a particular row of a block if any number occurs only in a particular row or column. If so, eliminate the possibility of occurrence of that number outside the block in that row or column. Follow step 1 every time you effectively use this step. This simplifies our possibility grid for a reasonable extend.

Check if all the cells have only one possible value then you have successfully solved the puzzle. If not you will have to implement the next method.

Step 3: see if a two numbers combination occurs only twice in a particular row and both numbers occur only in these two cells, and then these cells must contain only these two numbers. You can remove the other possibilities of occurrence of other numbers in these cells. Follow step 1, step 2 and again step 1 every time you effectively use this step.

Check if all the cells have only one possible value then you have successfully solved the puzzle. If not you will have to implement the next method.

Step 4: if the number of elements in the union of N cells in a row is equal to N, then you can remove the numbers in the union from all other cells in the row. The N can vary from 3 to 8. Apply this for columns and blocks also. Follow step 1, step 3, step 1, step 2, and step1 every time you effectively use this step.

Main loop: Now repeat these steps again and again until you get a unique solution. Most hard and Moderate puzzles are solved in the first loop itself, some complicated puzzles may have to go for further repeating all these steps.

The looping which is recommended at the end of each step is really effective on reducing CPU usage. If these inner looping is not used, the main loop has to go for more than 10 looping.

CodeTiger
Mobile Game Developer
Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
Board.RingsWorld.com » Games » Sudoku
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku: Latest Discussions
Sudoku World invitation
by Sudoku World - 739 days ago
AnytimeSudoku.net - frees sudoku portal
by kalyan - 905 days ago
Solving Sudoku
by Harvey - 973 days ago
Good Camel's Sudoku Solver!
by jon - 974 days ago
my soduku-solver site
by jon - 974 days ago
Free Sudoku puzzles and software
by jon - 974 days ago
Constellation Sudoku
by aman - 1012 days ago
Free Monthly Online Magazine (Advanced Players Only)
by matthew - 1018 days ago
Final Fantasy 7 for PS3?
by Urban Legend - 1058 days ago
Daily sudoku on your website
by aimien - 1062 days ago
Introduce yourself
by aimien - 1062 days ago
The definite method for the identification of XYZ wing
by IUSUT - 1067 days ago

Link to this Page

If you want to link to this page you can use the following URL:


Example:
 
The Sudoku Web-Ring Community
The Sudoku Web-Ring Community
The purpose of this Web-Ring Community is to bring together all the best sites and resources about the logical puzzle game: Sudoku
(108 members)

» Submit your site and Join The Sudoku Web-Ring Community

 
 

External Links
 

NewsLetter

0.17084503173828