Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

Soduku board generator PHP

 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku
View previous topic :: View next topic  
Author Message
omri

Joined: 29 Jun 2007
Posts: 4
:

Items
PostPosted: Fri Jun 29, 2007 3:03 pm    Post subject: Soduku board generator PHP Reply with quote

Hello, i am looking for a sudoku board generator in PHP
something that i can tell to give me a board with difficulty level that i give in advance
is such a PHP script available?
if now, if there a program that does that in any other language?
Back to top
View user's profile Send private message
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Fri Jun 29, 2007 10:58 pm    Post subject: Reply with quote

Hi & welcome.

Holiday time is approaching and school assignments are replaced by holiday fun projects Smile

Most generators just generate Sudokus of random difficulty. If you want Sudokus of a specific difficulty level, an online PHP generator will not make you very popular with your hosting provider, because such a program has to generate and solve puzzles in large quantities until a puzzle is found that meets your requirements. Depending on the number of expected visitors, it can bring the webserver down.

Here's how I do it:

1. Run a program overnight that generates 100,000 - 200,000 random Sudokus.
2. Run a batch solver the next night that solves and rates these puzzles. (SudoCue can do that)
3. Add all puzzles that meet one of your predefined difficulty levels to an online (MySQL) database.
4a. Have a PHP program that selects a random puzzle from this database when the user requests a puzzle of a certain difficulty level.
OR
4b. Make preselections from an offline puzzle database which are uploaded and made available for publication on specific dates.

Ruud
_________________
Meet me at sudocue.net
Back to top
View user's profile Send private message Visit poster's website
omri

Joined: 29 Jun 2007
Posts: 4
:

Items
PostPosted: Sat Jun 30, 2007 7:01 am    Post subject: Reply with quote

Thanks Ruud.

is there a program that will create the boards for me and rate them at the same time?
or maybe a libraries that i can use?
GNOME sudoku does generate rated boards perty fast, so i thoght about using its python engine, what do you think?

Also, you recommended SoduCue for solving
what do you recommend for generating?
Back to top
View user's profile Send private message
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Sat Jun 30, 2007 1:35 pm    Post subject: Reply with quote

A free command line generator by Guenther Stertenbrink and several other tools can be found here: http://magictour.free.fr/sudoku.htm

Glenn Fowler has a very versatile program that can generate, solve and do other weird things to Sudoku puzzles. His homepage is here: http://www.research.att.com/~gsf/sudoku/
_________________
Meet me at sudocue.net
Back to top
View user's profile Send private message Visit poster's website
omri

Joined: 29 Jun 2007
Posts: 4
:

Items
PostPosted: Sat Jun 30, 2007 1:58 pm    Post subject: Great Reply with quote

Thanks alot Ruud
Guenther Stertenbrink's generator looks good
but the easest boards i get out of it are harder then the easy boards i see in software like gnome-sudoku
thay use a pyhton script to generate the boards, did you happen to see it?

the other software has alot of option
but basicly it does the same for me, just create boards.
it dosnt rate them from what i see...

i think the python script is good.
Back to top
View user's profile Send private message
omri

Joined: 29 Jun 2007
Posts: 4
:

Items
PostPosted: Sat Jun 30, 2007 5:58 pm    Post subject: So i have the boards Reply with quote

OK, so I'm figuring out how to make boards with the program for att (lots of options I'm still reading on)

my next question is how do i rate them to easy hard very hard....

the boards i have look something like this

4....8....1...4..5.2.7..8...7...9.12.4.....5.23.4...7...3..5.8.1..8...2....9....1
4....8....1...4..5.2.7..8...76....12.4.....5.23....97...3..5.8.1..8...2....9....1
4....8...81...4......79.8...7...9.12.4.....5.23.4...7...3.15......8...29...9....1
4...2.1.7...6.....3.5..1..65....9.1.....7...32....6.7.6.3..5..4...8.....7...4.5.1
2.8..9..4..1.....3...1...87.2..5.......31.....3..8.......5...98..2.....63.4..7..1
...9.68.2......56.7....2...8.5..49..1.......6..93..1.8...2....4.37......2.18.3...
.5.9.6..2........771...2.....5..49..12.....56..93..1.....2...344........2..8.3.9.

(just lines with the output)
what rater would you recommend?
Back to top
View user's profile Send private message
Pat

Joined: 06 Sep 2006
Posts: 128
:

Items
PostPosted: Sun Jul 01, 2007 7:44 am    Post subject: re: Glenn Fowler's software Reply with quote

omri wrote:
OK, so I'm figuring out how to make boards with the program for att (lots of options I'm still reading on)

my next question is how do i rate them to easy hard very hard....

what rater would you recommend?


yes, a vast number of options

it (Glenn Fowler's software) does also rate the puzzles -- try without -f to get the default output format --
Quote:
.6.81.72.824..6........53...1....8...8.....1...9....4...21........6..235.98.42.6. # 277 FNTX C28.M/S2.p
-- the puzzle is followed by a "#" and then the first number is the rating

~ Pat
Back to top
View user's profile Send private message Visit poster's website
TriKri

Joined: 30 Jul 2007
Posts: 5
:

Items
PostPosted: Tue Jul 31, 2007 5:47 pm    Post subject: Reply with quote

Isn't it possible to geneate puzzles of certain difficulty levels? Why is it hard, is it because the difficulty will suddenly rice too much if you just remove one more clue, so it is hard to hit the right level, or is it because it is hard to judge at the same time as you solve it? Just curious. Smile
Back to top
View user's profile Send private message
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Tue Jul 31, 2007 8:48 pm    Post subject: Reply with quote

TriKri wrote:
Isn't it possible to geneate puzzles of certain difficulty levels? Why is it hard, is it because the difficulty will suddenly rice too much if you just remove one more clue, so it is hard to hit the right level, or is it because it is hard to judge at the same time as you solve it? Just curious. Smile

most random combinatorial objects exibit liittle structure
and structure is usually what makes those objects interesting

for sudoku "little structure" translates to "solves with singles"
i.e., most random sudoku puzzles will solve with singles

it is fairly difficult to program a generator to construct puzzles with specific structure
the typical method is to generate many random grids/puzzles and filter out the interesting ones
this trades off the complexity of programming specific methods for the simplicity of filtering
but at the expense of time -- some structures may require many puzzles to be filtered

there are a few rules of thumb for generating the hardest sudoku
and those are encoded by the -gH option of my solver

about the numerous options
my usual m.o. is the grand unix style -- many small programs, each for a specific task
I opted for one sudoku monolith to keep the sw management to a minimum
i.e., executable and documentation in one place


Last edited by gsf on Tue Aug 28, 2007 1:40 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
jido

Joined: 15 Aug 2007
Posts: 17
:

Items
PostPosted: Tue Aug 28, 2007 11:47 am    Post subject: Reply with quote

gsf, how does your generator make puzzles with jellyfishes etc? Does it generate various grids and filters the first one that satisfies the options requested?
Back to top
View user's profile Send private message Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Tue Aug 28, 2007 1:47 pm    Post subject: Reply with quote

jido wrote:
gsf, how does your generator make puzzles with jellyfishes etc? Does it generate various grids and filters the first one that satisfies the options requested?

yes, it uses the filtering
the -e expression option does filtering
each constraint/method has a single char name,
e.g., W for generalized x-wing
W0 is the #steps that required generlized x-wings
W1 is the #instances of generalized x-wings
W2 is the #instances of size 2 generalized x-wings (x-wings)
W3 ... swordfish
W4 ... jellyfish
H4 ... hidden quad
so to net puzzles with at least one jellyfish and hidden quad
Code:
-e "W4>0&&H4>0"
Back to top
View user's profile Send private message Visit poster's website
Pat

Joined: 06 Sep 2006
Posts: 128
:

Items
PostPosted: Tue Sep 04, 2007 1:03 pm    Post subject: re: "generalized X-wing" Reply with quote

gsf wrote:


W for generalized x-wing --
    W0 is the #steps that required generalized x-wings
    W1 is the #instances of generalized x-wings
    W2 is the #instances of size 2 generalized x-wings (x-wings)
    W3 ... swordfish
    W4 ... jellyfish


hey gsf,

what you call "generalized X-wing" of order j
is the (un-finned) fish of order j

by the way, i don't see W0 and W1 in your manual
    even W2, W3, and W4 are missing under "EXPRESSIONS"
Back to top
View user's profile Send private message Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Tue Sep 04, 2007 1:56 pm    Post subject: Re: re: "generalized X-wing" Reply with quote

Pat wrote:

what you call "generalized X-wing" of order j
is the (un-finned) fish of order j

by the way, i don't see W0 and W1 in your manual
    even W2, W3, and W4 are missing under "EXPRESSIONS"

hey Pat,
some of the nomenclature in my solver dates back to the first code
W was added 2005-10-21 when I realized that X cycles were not general enough to capture all swordfish/jellyfish configurations
(I had originally picked X for cycles because I thought they would cover all X-wing orders)
--man currently uses pure -- maybe that weasles me out of conflict
Code:
Wn Row/col claim: order <= n (4) pure x-wing/swordfish/jellyfish.

you're great at history -- when did fins come into the picture?

--man also has this general intro
Code:

EXPRESSIONS
  Expressions are C language style signed long expressions on constraint
  counters.  A constraint counter is named by the constraint identifier
  (case insensitive) and one optional digit.  The counters for constraint c:

    c   The number of constraint applications.
    c0  Equivalent to c.
    c1  The number of constraint placements.  Grouped modifications to a cell
        candidate list count as one placement.
    cn  Structure order 2<=n<=9 count (e.g., pair, triple, x-wing,
        swordfish).  c5..c9 are 0 for most constraints.

which applies to all constraint counters -- only specific exceptions are listed
so W2 is the number of order 2 W's, i.e., the number of X-wings
Back to top
View user's profile Send private message Visit poster's website
Pat

Joined: 06 Sep 2006
Posts: 128
:

Items
PostPosted: Tue Sep 04, 2007 2:30 pm    Post subject: re(2): "Generalized X-wing" Reply with quote

gsf wrote:

--man currently uses pure -- maybe that weasles me out of conflict
Code:
Wn Row/col claim: order <= n (4) pure x-wing/swordfish/jellyfish.


you're great at history -- when did fins come into the picture?


your manual is indeed OK on this -- my warning came in connexion with your post which used the dangerous term "Generalized X-wing" -- a term which i suspect indicated finned X-wing at a time when higher-order fish were not yet known!


no i don't really know the history but it seems to me that the finned X-wing was an early discovery -- earlier than Swordfish.
    now in the following post, is Sue De Coq referring to finned X-wing -- or to the Swordfish (as we now know it), which is indeed a way of generalizing the X-wing yet is entirely different from the "Generalized X-wing"? i'm certainly confused!
Sue De Coq (2005.Apr.27) wrote:

You might have followed the discussions on this and the Sudoku Programmers forum about the Generalized X-Wings (or Swordfish) technique.




gsf wrote:

--man also has this general intro

Quote:
EXPRESSIONS

Expressions are C language style signed long expressions on constraint counters.
A constraint counter is named by the constraint identifier (case insensitive) and one optional digit.

The counters for constraint c:
    c The number of constraint applications.
    c0 Equivalent to c.
    c1 The number of constraint placements.
    cn Structure order 2<=n<=9 count (e.g., pair, triple, x-wing, swordfish).

which applies to all constraint counters -- only specific exceptions are listed



yes, my fault, obviously Hn Tn Wn are all explained by the introduction

~ Pat
Back to top
View user's profile Send private message Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Tue Sep 04, 2007 3:48 pm    Post subject: Re: re(2): "Generalized X-wing" Reply with quote

Pat wrote:

your manual is indeed OK on this -- my warning came in connexion with your post which used the dangerous term "Generalized X-wing" -- a term which i suspect indicated finned X-wing at a time when higher-order fish were not yet known!

thanks -- I should have acknowledged that generalized was incorrect usage
I'll use pure to mean no-fins
Quote:

now in the following post, is Sue De Coq referring to finned X-wing -- or to the Swordfish (as we now know it), which is indeed a way of generalizing the X-wing yet is entirely different from the "Generalized X-wing"? i'm certainly confused!

my guess is swordfish because it goes on to describe how pappocom's sw at that time didn't recognize swordfish
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku All times are GMT
Page 1 of 1

 
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 Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron