Because WFC has to make a random decision when collapsing each cell, there's a chance it will choose a "wrong" answer and set itself up to get an unsolvable grid later on down the line. I have a problem that is likely to be unsolvable in most cases, but I'd still like the algorithm to try and find the solution that breaks the least amount of constraints.
The only method I can think of this is to take a snapshot of the grid every time a cell has to be collapsed, then proceed like normal. Once the algorithm solves the grid as much as it can, save how compliant it is then go back to the snapshot and choose a different state to collapse. Do this for every possible decision then the final answer will be the grid that is most compliant with the constraints. This is incredibly slow and memory intensive, does anyone else have an idea of how to modify the algorithm to find the best solution even if it's not 100% compliant? I'd like to avoid heuristics unless all other solutions take an unreasonable amount of time.