Re: SWI Prolog Sudoku
- From: russell kym horsell <kym@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 12 May 2007 04:37:44 +0000 (UTC)
JJ <rompeqk@xxxxxxxxxxx> wrote:
Hi, i'm new to prolog and i have to write a sudoku solver 2x2 and 9x9
for a class as a final project, can anyone tell me how do i do
that???? i read a tutotial online but i doen'st even tell me how to
make the grid or the rows and columns or how to put the values in it.
I got some code from the internet but everytime i try to run int it
gives me this error: Undefined procedure: domain/3. So is either i
don't know how to run it or there's something wrong with the file.
Sudoku problems are probably best solved by greedy methods.
I posit that's why thery're so popular for human players. :)
The method I've used some places is to take the puzzle and determine
which square has the least number of possibilities left. In many cases
there is only 1 possible digit that can go in a square.
Fill it in and loop back to start.
If you find a square with no possible digit youhave an insoluble Sudoku.
If it's due to one of your own guess then backgtrack.
If you find a square has more than 1 possible digit as
a solution, take a stab and choose one. Loop back to start.
A simplified version using no backtracking is simply restart the
whole solver if you end up with a square with no possible choice left.
This is like a "backtrack to the top" method. IMX it turns out to
offer the fastest possible solver on underpowered h/w like MP3 players
and cellphones. :)
.
- Follow-Ups:
- Re: SWI Prolog Sudoku
- From: debruyck
- Re: SWI Prolog Sudoku
- References:
- SWI Prolog Sudoku
- From: JJ
- SWI Prolog Sudoku
- Prev by Date: Re: SWI Prolog Sudoku
- Next by Date: Re: Business Rules in Prolog
- Previous by thread: Re: SWI Prolog Sudoku
- Next by thread: Re: SWI Prolog Sudoku
- Index(es):
Relevant Pages
|
|