At least in A mode where I've studied this sort of puzzle, not all 5x5 boards can be solved (I believe other sizes don't have this property). If you want to guarantee that you generate only solvable puzzles, you'll need to start with a blank board, and apply the cross pattern at each tile a random number of times. If you just set each tile to a random state, you'll end up with soft-locks