bonebreaker Posted January 24, 2007 Posted January 24, 2007 (edited) Hi, I used to program in pascal until this so i would realy appreciate any advice in making more faster and smoother my script. At the moment(v0.5) the program is able to: -generate sudoku (simmetrical ones), which can be solved for most of the time the next level is to make a number only appear maximum 4 times in the generated sudoku so it would be more like a real sudoku puzzle -puzzle solving sux at the moment, its ultra slow and it wont always work -you can make your own sudoku and save/load sudokus -etc, discover it what i dont know how to fix is making those number buttons send text in the inputboxes since focus goes on them as soon as they get clicked by the way thanks for slim shady, i learned many from his program on how to create a proper gui bonebreakerSuDoKu_v0.5.au3 Edited January 24, 2007 by bonebreaker My programs:[topic="40019"]Sudoku[/topic], [topic="41258"]Suitcase game & Random jokes[/topic], [topic="41641"]8 Queens[/topic], [topic="41679"]Puzzle Generator[/topic], [topic="42045"]Snake[/topic]My UDFs:[topic="41309"]Prime functions & Prime game[/topic]Other:Fake emailer
fisofo Posted January 25, 2007 Posted January 25, 2007 Dang... another one Hope you don't mind if I keep working on mine... Also, you may want to fix this: E:\Data\My Scripts\sudoKu_v0.5.au3(216,32) : ERROR: syntax error until $number2[$sim1][$j]) I haven't looked at the code too much yet, but how does your sudoku generator work? It appears you use random number generation, which can work as long as everything isn't random. Otherwise you may create unsolvable puzzles. Just a heads-up. That may be why your solver isn't working. Like you said: the solver needs work, you can borrow from mine if you'd like (I've just picked mine up again a couple weeks ago), in sig. Trying random numbers for solving is not a bad idea if you can get it to be fast. I was thinking I might try that at the end of my solver for figuring out insane puzzles. what i dont know how to fix is making those number buttons send text in the inputboxes since focus goes on them as soon as they get clickedBit confused here, do you want pushing a button to send that number to the active cell? If so, there's probably tons of ways to do it, here's one idea: -you could use $GUI_EVENT_PRIMARYDOWN and GUIGetCursorInfo to set a variable equal to the current control ID of the input box, then check that when a button is pushed. I'm sure someone has a better way than this though... I like the GUI btw, very small and simple (especially compared to mine! ). Keep it up!
bonebreaker Posted January 25, 2007 Author Posted January 25, 2007 The method of generating is quite simple since i am not finished with the better one yet: generate random numbers in each column until it can, if it can't generate anymore it deletes the last column and generates another. If it can continues it does, else it regenerates the same column for a few more times (as many time you desire), and if it fails to continue to the next column it deletes back another one... sounds dumb, maybe it is I use almost the same method for solving.. I am sure that if i can make that a number can only appear 4 times in the puzzle it will be solvable thx for the idea on the buttons, I will try it. My programs:[topic="40019"]Sudoku[/topic], [topic="41258"]Suitcase game & Random jokes[/topic], [topic="41641"]8 Queens[/topic], [topic="41679"]Puzzle Generator[/topic], [topic="42045"]Snake[/topic]My UDFs:[topic="41309"]Prime functions & Prime game[/topic]Other:Fake emailer
fisofo Posted January 25, 2007 Posted January 25, 2007 The method of generating is quite simple since i am not finished with the better one yet:generate random numbers in each column until it can, if it can't generate anymore it deletes the last column and generates another. If it can continues it does, else it regenerates the same column for a few more times (as many time you desire), and if it fails to continue to the next column it deletes back another one...sounds dumb, maybe it is I use almost the same method for solving.. I am sure that if i can make that a number can only appear 4 times in the puzzle it will be solvablethx for the idea on the buttons, I will try it.well, i hate to bring ya bad news, but most of the time that method will generate unsolvable sudokus. And actually, your "difficult" leveled one may generate sudoku's with multiple answers. I just ran a couple of the mediums through an online checker, and they are indeed unsolvable Sorry.The generating step can be quite difficult, which is why in mine I used a website to do it for me. Sorry I can't be more helpful, i'll post if I find anything more useful.
bonebreaker Posted January 25, 2007 Author Posted January 25, 2007 well, i hate to bring ya bad news, but most of the time that method will generate unsolvable sudokus. And actually, your "difficult" leveled one may generate sudoku's with multiple answers. I just ran a couple of the mediums through an online checker, and they are indeed unsolvable Sorry.The generating step can be quite difficult, which is why in mine I used a website to do it for me. Sorry I can't be more helpful, i'll post if I find anything more useful.Thanks for checking it, back to the drawing table seems so Or maybe i will stop this for a while and resume when i am more experienced in autoit, big fish for a first program.Btw your sudoku-it is relay nice i will try to figure out your solving method My programs:[topic="40019"]Sudoku[/topic], [topic="41258"]Suitcase game & Random jokes[/topic], [topic="41641"]8 Queens[/topic], [topic="41679"]Puzzle Generator[/topic], [topic="42045"]Snake[/topic]My UDFs:[topic="41309"]Prime functions & Prime game[/topic]Other:Fake emailer
fisofo Posted January 26, 2007 Posted January 26, 2007 Thanks for checking it, back to the drawing table seems so Or maybe i will stop this for a while and resume when i am more experienced in autoit, big fish for a first program.Btw your sudoku-it is relay nice i will try to figure out your solving method thanks! Don't let yourself get overwhelmed... just research that helpfile, use the forum search function and start having fun... As Breen would say: "Welcome... welcome to autoit", and welcome to the forums!
Kickassjoe Posted February 11, 2007 Posted February 11, 2007 a good method (I think) for generating sudoku's is generating a random number for a spot, and then checking to see if that number will fit in that spot, with the other numbers that are currently in the sudoku. Here is an example from my sudoku generating program. CODEGlobal $sudoku[9][9] For $x = 0 to 8 For $y = 0 to 8 $i = Random(1,9,1) If CheckColumn($i,$y) AND CheckRow($i,$x) AND CheckSquare($i,$x,$y) Then $sudoku[$x][$y] = $i Else $sudoku[$x][$y] = "" EndIf Next Next Func CheckRow($number,$x) For $y = 0 to 8 If $sudoku[$x][$y] = $number Then Return 0 EndIf Next Return 1 EndFunc Func CheckColumn($number,$y) For $x = 0 to 8 If $sudoku[$x][$y] = $number Then Return 0 EndIf Next Return 1 EndFunc Func CheckSquare($number,$x1,$y1) Local $square_x = Int($x1/3) Local $square_y = Int($y1/3) For $x = ($square_x*3) to ($square_x*3)+2 For $y = ($square_y*3) to ($square_y*3)+2 If $sudoku[$x][$y] = $number Then Return 0 EndIf Next Next Return 1 EndFunc I have no idea on what I am doing wrong solving them though, I check every square to see if that number will fit with the numbers that are in the sudoku, yet it still doesn't work somehow. This is not the most recent version of the script, and only part of it. (the whole script is in my sig, though not recent either, the recent version is on my other computer) What goes around comes around... Payback's a bitch.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now