eleven wrote:I think the questions i had, are answered sufficiently.
I hope your conclusion is that all puzzles are solvable by a non T&E procedure. By the way, which one came with 0 result? Please give me the string.
eleven wrote:The bad thing is, that i dont have an idea how to find a good order. Allways to take the band/stack with the least possible assignments in the units is often a bad strategy. I have the suspicion, that no better heuristics can be found, which dont take long to evaluate. So to define the order is a kind of guessing.
I hope you will at least agree that this kind of guessing is not that kind of guessing Sudoku players/programmers are talking about. But I will not use "guessing", I will use "strategy". I think the existing of choices and different strategies is good thing for Sudoku to continue to be a interesting puzzle game. I would say, if the true optimal could be easily computed, Sudoku would really be a dull thing, at least for programmers.
eleven wrote:Of course you could avoid any memory problems by doing this depth first. Take the first assignment for the first unit, then the first of the combination with the next assignment, etc, until you have nothing or a solution. And then ... backtrack. All you would need in memory is, to save how to get to the next solution per level. This can be easily done, when all these vector arrays are kept in memory for all levels (units to combine) - you can calculate them, as soon you have defined the unit order. Then you just need a pointer to where you are.
Then i cant see any performance advantage for the breath first method.
I object the thought of backtracking in any case, once you decide to use cogwheels as the backbone of your solution. I will describe a thought here that handle the memory problem more aggressively, even accelerating the solving time (at least for hard puzzle with potential memory explosion with current engaging order).
We should start with the problem:
1. 50% of cpu time is spent on non-intelligent operation(for hard puzzles): cloning or copying.
2. Many copies are simply pruned without utilisation -- what a waste of time (CPU) and space (MEMORY)! Why copy in the first place!
Now the reasoning / description of my new proposal, which should able to suppress the memory issue.
Which step in the algorithm actually help you narrow down the space? -- Prune, and prune only. When does that happen? When, and only when cogwheel circles are formed. Which step gives you the memory problem? Graft, and graft only.
The interesting thing I find is that Prune and Graft are two independent operation.. Therefore, In the function NodeEngage, you replace
- Code: Select all
If NextEngages is [ ]: //No moret engaging level, attach the subtree from s(g)
For each arc a common to MetaN and N:
MetaGraft(MetaN.sons[a], N.sons[a])
with
- Code: Select all
If NextEngages is [ ]: //No moret engaging level, return
return
you then get a prune-only version of engage(), which probably is no-longer proper to be called a engage(), so let us call this version -- "Intermesh()". Intermesh() will be useful at a moment I will call harping moment, because in the most typical form, the engaged groups form a shape somewhat like a harp whose strings are yet to be mounted.
Typical example of Harping moment (x's are cells that are covered by normally engaged groups. Their levels are already in tree c.)
- Code: Select all
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x
x x x
x x x
x x x
x x x
x x x x x x x x x
Each of C4-C9 will be the string of the harp, but engaging each string onto tree c will result in
1. some pruning of tree c because the string introduces some cogwheel circles, but also
2. many subtrees being grafted on the tree c (dramatically increasing the memory), because a string also come with five non-intersecting cells (in row4-8). And these cells do not (significantly) contribute to new circle formation any soon.
Pruning at this moment is overwhelmed by grafting (in hard puzzles) because of the weakness of the base of the harp.
My proposal at this moment is:
1. intermeshing C4-C9 onto tree c rather than engaging them onto tree c. This will accumulate prunning of the tree c before any unnecessary grafting is done!
2. after intermeshing them, normally engage one of these strings. Say, it is C9 being engaged.
- Code: Select all
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x x x x x x
3. What do we have now? Another harping moment. Now the strings are R4-R8. Then you basically repeat the procedure.
Say, at the end of this round of intermeshing, we choose to engage R8.
4. What happens now? We can re-intermeshing string C4-C8, because, engaged cells in R8 allow the string C4-C8 to form new cogwheel circles.