LazyTurtle / Sudoku-Solver

A Godot application that uses constraint programming to solve Sudokus.
MIT License
1 stars 0 forks source link

Update the initial partial assignment as soon as a new value is selected for a variable #4

Closed LazyTurtle closed 3 years ago

LazyTurtle commented 3 years ago

Right now, the initial assignment is created only when the user select to solve the sudoku. The creation of the initial assignment and, most importantly, the first pre-inference procedure take several seconds, often more than the actual solving of the puzzle through backtracking algorithm. A way to speed up could be to create an empty partial assignment from the get go and update it while the user is selecting the initial value for the sudoku, and start a smaller inference right after. This should avoid the 2 to 7 seconds that can pass before the solver actually start solving the CSP.

LazyTurtle commented 3 years ago

The update has been completed. Now the solver start solving the puzzle almost right away instead of making the first big inference procedure, which can take several seconds. It took more or less what I expected, fortunately I didn't have to completely decouple domains and variables, that would have been a major overhaul of the entire project. It takes a second in order to complete the inference of a single cell, but it doesn't seem to cause problem selecting many values one after the other and it should be improved when I improve the Inference and consistency check.