FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Interested to develop logics of Sudoku?





shenyl
Anyone interested to contribute to logics used to solve Sudoku?

Like assigning Status to each box, and a value to each box, use of array to store possible and fixed and confirmed values of boxes, for horizontal, vertical, diagonal and a 9-box cube rows (generated dynamically as each box is tested).

I hope contribution can be done, to enhance the logic of this game.

Look forward to more suggestions or directions.
shenyl
I did a search on Google and found this site very comprehensive in solving Sudoku logics.

Unfortunately, a little short of explaining the programming logics of the various methods.

http://www.sudokusolver.co.uk/solvemethods.html

I would really hope to see a good contribution here on this logics.

I am writing the C# OOP approach to solving this using objects approach.

Will post more details as I progress.

To start your appetite going, here is my game plan.

A class for each cell, with property - cVal (Single value), cStatus (Fixed, Testing, Confirmed, Failed), cPoss (A string with a separator for balance of possible values), and methods
to update the cPoss with a byte array.

A class for a game containing an 2 dimensions array of cell objects [row,col].
Similar to the spreadsheet approach.
This too has methods.

The game class will have a constructor method to instantiate with a cell[,] 2dim array of cell objects.

Fixed values are given values and cannot be changed
Confirmed values are solved values from eliminating all other values in the cPoss

Using iteration starting from a game object with fixed values.

Methods to update a row's cells cPoss values
A row can be horizontal, vertical, a block of X,X cells, or diagonally.

I will try and continue as I need to get back to my programming.

Will put more, and hope more to join in this craze.
{name here}
shenyl wrote:
Anyone interested to contribute to logics used to solve Sudoku?

Like assigning Status to each box, and a value to each box, use of array to store possible and fixed and confirmed values of boxes, for horizontal, vertical, diagonal and a 9-box cube rows (generated dynamically as each box is tested).

I hope contribution can be done, to enhance the logic of this game.

Look forward to more suggestions or directions.

I actually know of a program that will automatically solve this, but right now the site is down, and will be until I reconstruct the CMS. It's in QuickBASIC(works with FreeBASIC, too), and it's code isn't the best formed, but trust me, it works. You can probably learn from whatever code you can make out. BASIC isn't brain surgery. A person who knows C will most likely also understand the basics of BASIC code.
MrBlueSky
Here is a little program in Haskell which solves Sudokus.

Code:

import List

type T = (Int,Int) -> [Int]

main = do
  s <- getContents
  putStr $ unlines $ map disp $ solve [input s]

solve :: [T] -> [T]
solve s = foldr search s idx where
    search p l = [mark (p,n) s | s <- l, n <- s p]

mark :: ((Int,Int),Int) -> T -> T
mark (p@(i,j),n) s q@(x,y) =
  if p==q then [n] else
  if x==i || y==j || e x i && e y j then delete n $ s q else s q
  where e a b = div (a-1) 3==div (b-1) 3

disp :: T -> String
disp s  = unlines [unwords [show $ head $ s (i,j) | j <- [1..9]] | i <- [1..9]]

input :: String -> T
input s = foldr mark (const [1..9]) $
  [(p,n) | (p,n) <- zip idx $ map read $ lines s >>= words, n>0]

idx :: [(Int,Int)]
idx = [(i,j) | i <- [1..9], j <- [1..9]]


It is actually not very difficult to write a program that can solve all (solvable, valid) sudokus. The fun and difficult challenge is to write one which doesn't use any brute-forcing, but only logic. When trying to write a sudoku-solver myself I read Programming Sudoku by Wei-Ming Lee:



Table of Contents (PDF!)

It explains all the logic behind solving sudokus and how to implement it using Visual Basic, including a nice graphical user interface. You can download the source code and take a peek at it.
shenyl
The URL is incorrect, here is the updated URL

http://www.apress.com/ApressCorporate/supplement/1/10111/1590596625-3366.pdf

I have also reviewed the extract of Chap 2,

Wah, Wah - it is a full step by step development in .NET Framework on Sudoku.

I guess all my effort will be repetitive, but I am still keen to grasp the concept by doing it with the help of these gurus.

Thank you MrBlueSky - it is indeed a excellent reference book.


Thanks also to {name here} for your contribution to the solution.

I will try and pick up the book from my National library, else from the reference section.

Will get back for more news on progress and feedbacks.
Related topics
Frankfurt Motor Show, 2005
your weekly dose of fascism. Internet2 not for you?
Survey: Which type of advertisements are you interested in?
Sudoku Assistenten
Wilma Picks Up Speed, Heads for Florida
crystalxp [themes]
PHP-Nuke Services
DO YOU SUDOKU?
New PHP framework comming up
Paying f$ for content written for my site.
Urban Legends About the Iraq War
Sudoku
An algorithm to solve sudoku
Gamedevelopment
Reply to topic    Frihost Forum Index -> Computers -> Software

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.