Red Ed wrote:gsf wrote:if you just want a stream of grids try
- Code: Select all
sudoku -g -T0x80 -f%v
Much better: 10.68.
Interesting that gsf's program has a very slight preference for creating size-4 unavoidables in near the top left of the grid, over creating them near the bottom right. But with speed like that, who's complaining? ( Actually, for the purposes of this thread, I am
)
the generator works in two stages
first stage generates a valid solution grid (81 clues)
it starts with a full pencilmark grid and selects a random cell with >1 candidates
and then selects a random candidate in that cell and makes it a clue
pencilmarks are propagated and invalid grids are tossed
at the 27th clue assignment the grid is solved with unique solution check enabled
unique solutions are sent to the second stage, otherwise the first stage is restarted
second stage fills an empty grid using clues from the solution grid
no validation is needed because the clues are taken from a valid solution grid
after 16 clues are filled (might as well do a < 17 clue stab) the singles backtrack solver
is used to check for unique solution
so at least some of the bias is in stage 1, in at least 2 places
the magic "27" was chosen to minimize the number of (heavyweight) solver calls
vs the number of (lightweight and amortized) pencilmark validations
its also goofy to throw out multi-solution puzzles in a solution grid search
since two valid solution grids are tossed -- it should take the first solution
as a gift and pass that on to the second stage
I'll rectify that but I won;t be able to update www until monday
as for upper-left vs lower right bias, isn't that an automorphism wash?
i.e., the grids could be randomly permuted to eliminate that, no?
the "random" selections are based on a 64 bit PRNG (cycle 2^64)
I do have a question on the difference between -T0x80 and not
Red Ed, are you measuring bias on solution grids or puzzle grids?
I had assumed you were measuring solution grid bias
if so then here's and experiment for you to crunch:
with -T0x80 valid solution grids (no empty cells) are generated
without -T0x80 valid puzzles (with empty cells) are generated
if you make two runs with the same PRNG seed N (-rN)
the non-T0x80 run will have the same solution grids as the -T0x80 run
(you can use -nN to limit the run to N puzzles)