Clean, readable breakdown of the MakeChoice -> Backtrack -> UndoChoice skeleton—keeping the state mutation and undo symmetric is what saves hours of debugging once constraints get messy.
When adapting this exact template for 2D grid puzzles in the browser, we found that ordering GetOptions(State) by most-constrained cell first makes a night-and-day difference in branching factor:
For Exact-Cover tetromino packing (irregular grids up to 8×8 with clockwise-only rotations and no flipping), anchoring on the first uncovered cell slashes redundant permutations.
For 6×6 mirror raytracing and pipe-flow grids, validating beam/flow continuity inside MakeChoice lets you backtrack the moment a loop or leak forms instead of waiting for IsComplete.
We used that exact structure across the browser-side solvers in our independent fan puzzle studio, Talebound Puzzle—documented in our Tetrendreth Tetris Solver Guide (unofficial fan tool, not affiliated with Blizzard). Thanks for putting together such a practical template!
linxi ye
Clean, readable breakdown of the
MakeChoice -> Backtrack -> UndoChoiceskeleton—keeping the state mutation and undo symmetric is what saves hours of debugging once constraints get messy.When adapting this exact template for 2D grid puzzles in the browser, we found that ordering
GetOptions(State)by most-constrained cell first makes a night-and-day difference in branching factor:8×8with clockwise-only rotations and no flipping), anchoring on the first uncovered cell slashes redundant permutations.MakeChoicelets you backtrack the moment a loop or leak forms instead of waiting forIsComplete.We used that exact structure across the browser-side solvers in our independent fan puzzle studio, Talebound Puzzle—documented in our Tetrendreth Tetris Solver Guide (unofficial fan tool, not affiliated with Blizzard). Thanks for putting together such a practical template!