Post by Mike SandersPost by Janis PapanagnouPost by Janis PapanagnouIs there a reference for the design of the algorithm existing?
Probably several I'm guessing.
Speaking about "solvable" punctured (and guaranteed) solvable code
strings, I haven't found any references. (That's why I'm asking.)
Post by Mike SandersPost by Janis PapanagnouPost by Janis PapanagnouI'm curious, e.g. about the rationale for the choice of the
mgx = "..." value, for the initial order of the numbers
(before the rows and columns are getting shuffled). Is it a
specific (sort of) "universal" value, or is it one of a couple
existing sequences that have good properties for the task?
mgx[1] = "123456789456789123789123456214365897365897214897214365531642978642978531978531642"
mgx[2] = "415326789239785416678941235754198623196234857823657194341579862582463971967812345"
mgx[9] = "193724685526819347487653192852491763614237958739568214248975631361142579975386421"
mgx[3] = "123456789456789123789123456214365897365897214897241365532614978641978532978532641"
mgx[4] = "312645978654978123978123654231456789465789231789231465143592867527864391896317542"
mgx[5] = "123456789456789213789321456231468597564297138897135624318654972945712368672943851"
mgx[8] = "315694278628753491479128365132546987764981352985237614243867159857319426961425783"
mgx[6] = "123456789456789123789123456231465897564897231897231564312654978645978312978312645"
mgx[7] = "123456789456789123789123456231465897564897231897312564315648972648972315972531648"
Okay. But my previous question whether 'mgx' is defined in a way that
supports producing unambiguous puzzles is now just extended to every
'mgx[i]'; do these mgx[i] have properties to guarantee unambiguous
puzzles?
Post by Mike Sanderssrand()
current_board = mgx[int(rand() * 9) + 1]
Yes, my algorithm is designed to create consistent variants on the fly,
based on the normalized matrix
[
1,2,3, 4,5,6, 7,8,9,
4,5,6, 7,8,9, 1,2,3,
7,8,9, 1,2,3, 4,5,6,
2,3,4, 5,6,7, 8,9,1,
5,6,7, 8,9,1, 2,3,4,
8,9,1, 2,3,4, 5,6,7,
3,4,5, 6,7,8, 9,1,2,
6,7,8, 9,1,2, 3,4,5,
9,1,2, 3,4,5, 6,7,8
];
Then consistent number-mapping and consistent row/column-shuffling
is done. Which at least produces valid solutions. But, with a random
zapping, unambiguous puzzles are not guaranteed here. So the choice
of the initial array is crucial!
Post by Mike SandersPost by Janis PapanagnouFor the HTML/JS version that I mentioned elsethread I observe
that often there's sheets with ambiguities generated. From some
online resources I've got the impression that you (generally?)
need a Sudoku solver to check the board after generation and if
the test fails then discard the board and retry the generation.
In your Sudoku-script you have used two (arbitrary?) constants
that affect the generation; the initial values in the matrix
before the random shuffle ('mgx') and the number (10) of shuffles.
I'd be interested whether these choices positively affect the
generation generally and the avoidance of ambiguities specifically.
A design reference that can enlighten the issue would also help.
Actually, my solution has been called naive, what I'm not so naive about
is p vs. np =)
(Oh, my post was not meant as criticism for your approach.)
But maybe this statement implies that 'mgx' does not have any special
properties to prevent ambiguities? - If so, that's okay for me. I was
merely looking for sophisticated _design principles_ - *if* they exist
in the first place.
Post by Mike Sanders- every game is winnable
- no 1000's of iterations validating *every digit* on a board built
from scratch
- millions (upon millions) of permutations once shuffled & yet millions
more when 'zapped'
(I was not asking for solving NP complete problems.)
Post by Mike SandersWhy fuss around getting your work to market when you can instead think
differently? That's my rationale.
I'm looking for data sets (or likewise algorithms) that produce
(guaranteed) solvable puzzles.
Post by Mike SandersAnyhow, (a very, very basic explanation) just start with a winnable
game, a flattened-out string...
It boils down to: what is a "winnable game [...] string".
Post by Mike Sanders123456789578139624496872153952381467641297835387564291719623548864915372235748916
Break it down, step by step...
[...]
Then swap some columns & rows...
[...]
& randomly zap...
Good luck Janis, I think you have what it takes to get the job done =)
Well, the random swaps etc. is what I already did from the beginning.
The question is what you mean by
"start with a winnable game, a flattened-out string"
This string that I use is consistent but is this one "winnable"?
123456789456789123789123456234567891567891234891234567345678912678912345912345678
Or a permuted and substituted one derived from that string? I'd say:
No. - Because I could apply simple zaps that produce ambiguities.
If the 'mgx' string is "better"
123456789578139624496872153952381467641297835387564291719623548864915372235748916
I'd like to know why; what are the properties, how are they obtained,
or is it just copied from a source that had only reliable string(s)?
This is the simple but crucial question!
Post by Mike SandersMust go now & more experiments in the days ahead, some boring yet practical,
others more exotic. Its all good.
* For reference, I've 10,000 boards in a zipped plain text file where the
top row is: 123|456|789. There are simply too many possible combinations
to store on my hard-drive. And dont worry about a 'fixed' string, there
are more games possible with a single string than you and I could play
in all our lives combined.
I probably wasn't able to make my point clear.
If I'd knew that 'mgx' is a string with good properties (i.e. always
"winnable") then I could just use algebraic permutations on it (as I
already apply them for my initialization string). - If the answer is
"Yes" I'd just use it.
And is one string "better" than others. (And I'm certainly interested
in design principles of these strings. Likewise a database of already
existing strings; no need to duplicate effort.)
Otherwise I'll have to go the path that I found described in several
sources; to create a random board, zap numbers, and test the outcome.
(This test would *not* be a NP complete task.)
Although I tried to comment on each part of your extensive post I
think the answer to the basic question I have can be given simply.
Janis