[Project Idea]Sudoku
#1
Posted 10 March 2013 - 05:38 PM
#2
Posted 10 March 2013 - 05:52 PM
#3
Posted 10 March 2013 - 07:09 PM
#4
Posted 10 March 2013 - 07:53 PM
#5
Posted 10 March 2013 - 08:02 PM
#6
Posted 10 March 2013 - 08:11 PM
Cranium, on 10 March 2013 - 07:09 PM, said:
Counting to 9, real difficult math.
I wish everyone who tries this the best of luck!
#7
Posted 10 March 2013 - 08:20 PM
. . . . . . . . 1 . . . . . . . . 2 . . . . . . . . 9 . . . . . . . . 4 1 2 3 4 5 6 7 8 ?
The code basically goes through the current row, column, and box it's in, and finds all possible numbers that can fit in that box, then throws in a random number from those possibilities. However here, you see the only possibility for the fifth row is 9, yet that's already taken in the 9th column.
My second algorithm, choosing a bunch of random rows while continually checking if it fits the puzzle, works, but is slow as hell. Takes 30 seconds to make one puzzle, and that's without checking boxes of 3x3.
Good luck to whoever can take this on and succeed better than I could.
#8
Posted 11 March 2013 - 12:08 AM
Kingdaro, on 10 March 2013 - 08:20 PM, said:
. . . . . . . . 1 . . . . . . . . 2 . . . . . . . . 9 . . . . . . . . 4 1 2 3 4 5 6 7 8 ?
The code basically goes through the current row, column, and box it's in, and finds all possible numbers that can fit in that box, then throws in a random number from those possibilities. However here, you see the only possibility for the fifth row is 9, yet that's already taken in the 9th column.
My second algorithm, choosing a bunch of random rows while continually checking if it fits the puzzle, works, but is slow as hell. Takes 30 seconds to make one puzzle, and that's without checking boxes of 3x3.
Good luck to whoever can take this on and succeed better than I could.
my code so far.
It generates a game with nil elements because it runs out of possibility.
http://pastebin.com/UWpYhmvR
and with that I have no idea where to turn ??
#9
Posted 11 March 2013 - 01:40 AM
123
312
231
We end up with 6 tables;
Horizontal Tables:
hLine1 = {1,2,3}
hLine2 = {3,1,3}
hLine3 = {2,3,1}
Vertical Tables:
vLine1 = {1,3,2}
vLine2 = {2,1,3}
vLine3 = {3,2,1}
Then if runs checks with each table, looking for double ups or even triple ups, then looks for what numbers are missing in that particular line. Taking said variables from the checks it regenerates the numbers with an algorithm designed to take both X and Y axis and figure out which particular number can fit in both at a certain point.
My method could just be over thought and I can see some issues when running an algorithm for the redrawing of numbers, for example you might have nothing that can fit in both lines because you have something like
1
1,2,3,0,5,6,7,8,9
3
4
5
6
7
8
9
Where there is the number 4 missing in the X line but in the Y the number 2 is missing.
Again, its just my train of thought on how to do this, I'm not really thinking about it too hard, too early in the morning
#10
Posted 11 March 2013 - 02:24 AM
Repeat untill youve got 9 valid cells..
Then remove random numbers to complete the puzzle.
this would give 2 problems:
It is not certain if the puzzle is solvable (you would need to make a sudoku solver to check this)
It is not certain if there is only one solution (this would need an even more advanced sudoku solver)
I will have to try this method out soon...
#11
Posted 11 March 2013 - 04:19 AM
#12
Posted 11 March 2013 - 04:46 AM
Maybe the fresh light of day will help.
#14
Posted 11 March 2013 - 05:04 AM
#15
Posted 11 March 2013 - 05:35 AM
Bubba, on 11 March 2013 - 05:02 AM, said:
I'd port this if I knew VB. Visual Basic's Syntax Reminds Me Of Those People Who Capitalize The First Letter Of Every Word They Say.
#16
Posted 11 March 2013 - 07:15 AM
This (quite interesting) video shows some of the requirements for a valid sudoku puzzle..
EDIT: so now that we know what to keep in mind when creating a sudoku, and we have ourselves a valid sudoku generator (Orwell's generator uses the method described be bubba's link), the next step is to make the valid sudoku grid into a puzzle!
So we can erase numbers (or make them invisible) untill at least 17 numbers remain, of which 1 number is part of the magic pair or whatever numberphile called it..
#17
Posted 13 March 2013 - 01:08 AM
It won't be pretty and anyone who is actually good at LUA will probably think what the hell am I doing with random lines of useless code everywhere.
#18
Posted 13 March 2013 - 03:22 AM
Kryptanyte, on 13 March 2013 - 01:08 AM, said:
It won't be pretty and anyone who is actually good at LUA will probably think what the hell am I doing with random lines of useless code everywhere.
The hardest part is going to be writing an algorithm to make sure the puzzle is actually solvable.
#19
Posted 13 March 2013 - 07:41 AM
425
168
973
-----
842
791
356
See the 9 and the 7? thats what I mean
#20
Posted 15 March 2013 - 12:16 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











