
Originally Posted by
Pete_UK
Years (and years) ago (in the 1980's) I wrote a program to generate sliding block puzzles on a 3 x 3, 4 x 4 or 5 x 5 grid (user-selectable - I used letters of the alphabet, so couldn't allow it to be bigger), and I just generated a number of random moves to begin with. This did create unwinnable situations. I got round it by generating random numbers in the range 1 to 4 where each number represented a direction (up/down, left/right) and effectively moved a tile into the "blank" from those directions.
Bookmarks