So I have a random 15-puzzle, or any N-puzzle with even width, and I also have a random goal-state. That is, the blank tile and other tiles are also randomly placed.
I am able to check if the 15 puzzle is solvable with the standard goal state of having the tiles in order and blank in the bottom right, but randomizing the goal state seems to be more tricky than the standard 8 puzzle.
Example:
Start State
8 4 1 6
11 2 3 10
15 12 0 9
14 5 7 13
Goal State:
11 4 1 0
8 2 3 10
5 15 6 9
12 9 7 13
The rules for the standard 15-puzzle solvabilty are:
If the width is odd, then every solvable state has an even number of inversions.
If the width is even, then every solvable state has
An even number of inversions if the blank is on an odd numbered row counting from the bottom;
An odd number of inversions if the blank is on an even numbered row counting from the bottom;