Grid Puzzle Solvability

138 Views Asked by At

I've created a unity game which is sort of like a flat two sided Rubik's Cube. There's a grid (with a dynamic number of rows and columns) and set of tiles numbered from 1 to rows*columns. These tiles are randomly placed on the grid, and the goal is to put them back in order with 1 in the top left. When you click on two adjacent tiles, the row or column of tiles shifts, and the tile that gets pushed off the grid reappears on the opposite edge. If you push it off the right it reappears on the left, if you push it off the top, it reappears on the bottom, and vice versa. However, some randomized initial positions lead to unsolvable states. Is there some sort of equation for the solvability of a puzzle like this, similar to the solvability equation for the 15-puzzle?