A visualization of the wave function collapse algorithm used here to solve a sudoku problem.
sudoku.mp4
It can also be used to solve more esoteric sudoku such as the miracle sudoku by Mitchell Lee, solved by cracking the cryptic
sudoku.mp4
In this version,
Normal Sudoku rules apply. Any two cells separated by a knight's move or a king's move (in chess) cannot contain the same digit. Any two orthogonally adjacent cells cannot contain consecutive digits.
The animation was made using Haskell reanimate. With a lot of help from the N-queen problem article.
You can specify and modify the rules for the game by editing Rules.hs.
The format for the input sudoku is a txt document with 0
s for empty squares and numbers for the given cells. For example:
0 0 0 0 0 0 0 3 0
0 9 0 6 8 0 0 0 5
0 4 2 0 1 0 6 0 0
0 2 0 8 0 0 0 0 0
0 0 1 0 0 0 0 0 0
4 0 3 0 0 0 0 0 9
0 0 0 0 0 0 0 2 0
6 8 0 1 0 0 4 0 0
0 0 0 0 0 4 0 0 3
I have found the best results by generating an mp4:
$ stack build
$ stack exec animate.exe -- render --format mp4 -o sudoku.mp4 -w 1280 -h 720 --fps 24
This visualization however isn't perfect as it does not show off the stack or any backtracking.