PDA

View Full Version : [Request] Sudoku-Script


Solo0815
2006-01-11, 21:44
is any1 out there, who wants to code a sudoku-script?
here is a link which my be helpful:
http://www.setbb.com/phpbb/?mforum=sudoku

thx in advance

Asteron
2006-01-14, 12:32
i actually wrote a sudoku solver/generator script (not xbmc) months ago and have been thinking about wrapping an xbmc gui around it. i got stuck on the interface. can you think of a pretty way to input the numbers or mark possibilities?

my script uses logic to solve and so can do stuff like provide hints via direct implication... it also supports non-standard sizes and variations like colored squares and diagonal constraints... in generating scripts there is the option of differing symmetries as well (diagonal double-diagonal quarter rotation x-flip xy-flip etc)... but right now it is all text... if you could describe how you want this script to function/look/behave that would be very helpful!


i went kinda nuts over it for a while and so have a lot of raw material to work with but dont know a good way to work it into an xbmc experience.

darkie
2006-01-14, 17:01
i went kinda nuts over it for a while and so have a lot of raw material to work with but dont know a good way to work it into an xbmc experience. this is funny. i wrote a bit of the gui, but i had no idea for how to randomly generate a grid so i didn't spend any more time on it. maybe we can work something out??

Solo0815
2006-01-14, 19:04
i hope you 2 find a way working together! :o

to input the numbers, you can use a 9-digit-pad on the screen. where, for example, if you press "x" the number is "fixed", if you press "y" the number is a "candidate". then we need 9-cell-sqare at the left or right to display the candidates for the sudoku-cell. the numbers in the square should change if you select another sudoku-cell.

buttons we need:
* hint
* solve the sudoku
* reset the sudoku
* undo

i hope you understand my suggestions, because english is not my native language (i´m german). my last english @school was a few years ago ;)

C-Quel
2006-01-14, 19:31
if this goes ahead... try to make it remote control friendly be nice to finish watching a movie then relax with some sudoku without unwrapping my controller :)

Asteron
2006-01-14, 22:17
if this goes ahead... try to make it remote control friendly be nice to finish watching a movie then relax with some sudoku without unwrapping my controller :)
great ideas :) i'll go ahead and modify my code to be less command line oriented. the interfaces i can provide would look something like this

difficulty,board = generator.generateboard(symmetry, optimized, [other options?])
difficulty,board = generator.fromfile(board.cfg)
solvedboard = board.solve()
square,logic_type = board.gethint()

generating boards is relatively easy (after you program a solver) but generating difficult boards is pretty hard. you still might want to have a button to grab a board from an online database like http://www.menneske.no/sudoku/eng/

darkie do you want to try putting the two pieces together or should i?

darkie
2006-01-16, 10:04
darkie do you want to try putting the two pieces together or should i? i think it is better if you give it a try. i don't have the script here at this moment, will try to send it a bit later this day to you.

Asteron
2006-01-16, 11:20
mk... send what you have to me asteron at optonline .dot. net and ill whip something up eventually.

luna
2006-01-17, 22:42
another gpl'd python sudoku source: http://pythonsudoku.sourceforge.net/
cheers,
luna

Asteron
2006-01-18, 02:31
another gpl'd python sudoku source: http://pythonsudoku.sourceforge.net/
cheers,
luna
i checked out the code, while his is better commented mine looks somewhat more powerful and a lot more generalizable.

of course logic in this script won't be too important as it will only really be used to give hints and help generate the board more quickly. (a brute force solver requires no logic and will solve every sudoku... allbeit very inefficiently)
it is still kind of hard to generate truely difficult boards... that's why i may still have to hook into that online database.

in anycase i have received darkie's user interface and it is quite usable... though it definitely needs some skinning work i think. if anyone wants to help prettify it that would be great :)

Asteron
2006-01-24, 19:57
did some more work on this and the generator / ui are talking to eachother right now. the generator works great for making some quick sudoku's but for harder ones the optimization routines run too slow so i will likely support grabbing them from the internet as well.
(in optimization i remove as many of the givens as i can and check to see if it is still solvable). i might be able to tweak the logic some more though to get more bang for the buck as generating sudokus is more of an art than a science (i make qualitative decisions as to which square should be fixed as a given and which value i should fix it to. if you are too agressive in the fixing though you can end up with an impossible board and have to backtrack alot.)

i still need to provide an interface for the generator, get hints out of my solver, and maybe provide support for variations like diagonal constraints, disjoint (colored) regions, no boxes...
will probably also number the puzzles so that they can be replayed in the future. lots of ideas...

anyway i will try to get a first version out sometime this week. this thing though really needs a good skin...

-ast

Livin
2006-01-24, 21:59
nice! i've not played this yet but everyone is raving about it. i'll do it once it is on xbmc!

mrz
2006-01-30, 17:08
i have published a sudoku script for xbmc (http://www.xbmcscripts.com/index.php?option=com_docman&task=search_result&itemid=array&search_mode=phrase&search_phrase=sudoku_v0_99).

enjoy,

matz

Asteron
2006-01-30, 19:52
well that really takes the pressure off :) the code looks pretty clean but i havent tried running it yet though. i need to check it out tonight and see if mine will have something to offer...

Asteron
2006-01-31, 05:14
hi mrc. just played with your version some and there is definitely some neat stuff in there.

however there is what i would call flaw in the generator in that it can generate puzzles with multiple solutions. it looks like the strategy that the generator uses is that it fully populates the initial grid, permutes it and removes squares. the problem is that if your initial grid contains a rectangle with corners

xy
yx

with none of those as givens then y,x can be switched and there is no way to figure this out logically. most consider this an error.

there are other cases too like

xyz
zxy
yzx

the only way to detect stuff like this though is to try to solve it logically... (do a backtracking solver and attempt all combinations).

HarshReality
2006-01-31, 05:29
anyway i will try to get a first version out sometime this week. *this thing though really needs a good skin...

-ast
let me know and i'll give it a go... have been working with scripts to simplify skins as of late but wouldnt mind trying from the ground up ;)

mrz
2006-02-01, 15:10
hi asteron!

you are right.
i tried to work around the pair thing by always keep one of the four digits in a pair group. triplets i did not think about.
need to look into this again. it should be possible to use my shortcut approach if only programmed right.

mrz

Solo0815
2006-02-02, 11:43
@ mrz

i tried your script yesterday evening. it works fine, but i´ve got some feature suggestions: :)

1. please change the button-setting. i was listening to music and wanted to play sudoku. but everytime i press "x" the fullscreen-vis showed up. i had to stop music while playing sudoku. it was veeeery silent im my living room ;)

2. how about 10 "savegames", not only 1. so my wife can play her sudoku and i can play mine ...

3. can´t remember now (i´m @ work). is there a hint button? it should show one number you can set.

mrz
2006-02-02, 21:12
hi solo!

i'm using the dvd-remote and was not aware about the x-button problem. this will be fixed.
i will also look into the problem asteron described. multisave as well as download from sudoku.com is in plan for the next release.
the number hint is always dsplayed below the grid this needs an on/off function.

finally i was thinking about a peer to peer function allowing competition over internet. you would then see the other players progress which then adds an element of stress.

thanks for the feedback

mrz

Nuka1195
2006-02-04, 18:28
this is a nice script.

a couple very minor suggestions.

1. copy folder.jpg to sudoku.tbn
2. on higher resolutions this works better as a dialog. not sure what it looks like in pal. or #3
3. use the setcoordinateresolution().

edit: #3 i had the wrong script open.

Asteron
2006-02-04, 18:35
hi all
i thought people might be interested in this wip now i have the core functionality is down. this takes a very different approach from mrz's script. features

1. logic based hints immediately derivable from the current board (hit b)
2. generate sudokus of 9 types of symmetry (i think i know a way to speed this up)
3. grab sudokus from the internet (i got permission from websudoku.com and menneske.no)

http://rapidshare.de/files/12544618/sudoku_deluxe.zip.html

the interface needs a lot more work and i plan on putting information on the right side (timer,remaining,symmetry,extra constraints, id, source). the core interface is there though (except marking candidates somehow) but there are so many options still needed.

i am really putting this out there to see if anyone wants to lend a hand in skinning it or has interface advice.

-ast

rcrh
2006-02-09, 20:24
i have published a sudoku script for xbmc (http://www.xbmcscripts.com/index.php?option=com_docman&task=search_result&itemid=array&search_mode=phrase&search_phrase=sudoku_v0_99).

enjoy,

matz
this script seems to have been pulled. any idea why?

thanks.

Asteron
2006-02-09, 20:36
that means it is being updated. the site doesnt keep scripts up after an update request for some silly reason.

Solo0815
2006-02-23, 12:40
:bump:

any updates?

i´m not a graphical artist, so i can´t help with graphics ...