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   

A decent method for creating puzzles?

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

Joined: 11 Aug 2005
Posts: 29
:

Items
PostPosted: Tue Oct 25, 2005 11:39 am    Post subject: A decent method for creating puzzles? Reply with quote

Having finally made a start on generating puzzles, i'm not sure that the quality is that good. I would appreciate any ideas on how to improve this method:

For cells 1 to 81:
Pick a random number 1-9,
If does not invalidate the puzzle, add.
Else step back a number of cells (random between 2-8).
Repeat this process until full grid is generated.

Next pick a number from the range (1,41)
Pick it's symmetrical equivalent (i.e. 1,81 2,80 etc)
Remove both numbers from puzzle.

After a set number of pair removals (20-30) try solving.
Keep removing pairs (<41) and solving until unsolvable.
If unsolvable, add pair back to list and try again a maximum of 3 times.
Save last solvable puzzle.

This method either creates extremely easy or extremly hard puzzles. Medium ones are extremly rare. Can anyone enlighten why??
Back to top
View user's profile Send private message Visit poster's website
Lardarse

Joined: 06 Sep 2005
Posts: 11
:
Location: Bristol, UK

Items
PostPosted: Wed Oct 26, 2005 7:41 am    Post subject: Re: A decent method for creating puzzles? Reply with quote

Paul wrote:
Having finally made a start on generating puzzles, i'm not sure that the quality is that good. I would appreciate any ideas on how to improve this method:

For cells 1 to 81:
Pick a random number 1-9,
If does not invalidate the puzzle, add.

It would be better to pick from the possible numbers left.

Quote:
Else step back a number of cells (random between 2-8).
Repeat this process until full grid is generated.

I would say to only remove random numbers after you have tried a few times and failed to put numbers in.

Quote:
Next pick a number from the range (1,41)
Pick it's symmetrical equivalent (i.e. 1,81 2,80 etc)
Remove both numbers from puzzle.

If you would prefer to go down the route of not having to be symmetrical, then you would just remove one number at a time.

Quote:
After a set number of pair removals (20-30) try solving.
Keep removing pairs (<41) and solving until unsolvable.
If unsolvable, add pair back to list and try again a maximum of 3 times.
Save last solvable puzzle.

Sounds good.

Quote:
This method either creates extremely easy or extremly hard puzzles. Medium ones are extremly rare. Can anyone enlighten why??

I will defer to the people that have written generators...

LA
Back to top
View user's profile Send private message
Paul

Joined: 11 Aug 2005
Posts: 29
:

Items
PostPosted: Wed Oct 26, 2005 8:47 am    Post subject: Reply with quote

Thanks Lardarse,

Quote:
It would be better to pick from the possible numbers left.


Good idea, i should eliminate numbers before picking.

Quote:
I would say to only remove random numbers after you have tried a few times and failed to put numbers in.


I now eliminate until a number is found or until i run out of numbers. Only then do i 'fail' and step back.

Will let you know how i get on this time...
Back to top
View user's profile Send private message Visit poster's website
Paul

Joined: 11 Aug 2005
Posts: 29
:

Items
PostPosted: Tue Nov 01, 2005 10:34 pm    Post subject: Reply with quote

Just like to say that i used the advice, and am very happy now with the generator. Very slow, but hey, quality over quantity Very Happy

Anyway, some examples off the production line:

Code:
.19......
.3....5.2
8...6..49
...3.24.1
.........
1.24.8...
28..5...6
9.4....7.
......35.


Code:
..4.....6
86.41....
...3.6...
15....6..
2...3...4
..8....25
...5.9...
....61.92
5.....7..


Code:
9....5.7.
..69...18
..16.....
.5....9..
.3.7.8.4.
..4....2.
.....41..
84...63..
.6.2....4
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