I recently shipped PrismTrail , a small laser-maze puzzle game for iOS and Android, built with Flutter. You tap mirrors to flip them between / and \ , and the beam has to reach a prism. Later levels add rings that teleport the beam, one-way glass, linked mirrors that turn together, and gates that open when a matching receiver is lit.
Players forgive a hard level. They don't forgive a broken one. So I set one rule early: no level ships unless a program has proven it is solvable, and knows the shortest solution.
The state space is small, so search all of it
Every level has at most four mirrors. Each mirror has two orientations, so the mirror state fits in a 4-bit mask. Gates add a little more state: once a receiver is lit, its gate latches open. So a game state is (mirror bitmask, set of opened gates) .
That is tiny. Instead of sampling or hand-testing, the generator runs a plain breadth-first search from the starting state over every reachable state.…