It's not cheating if you write the video game solver yourself | Robert Heaton
A programmer gets stuck on a puzzle game, writes a solver using finite state machines and breadth-first search, and discovers that explicitly modeling the problem space reveals solutions that intuition misses—even before the code finishes running.
Read Original Summary used for search
TLDR
• Cocoon's puzzles can be modeled as finite state machines because they have discrete states (your location, which orb you're holding, where other orbs are) and well-defined transitions (walk, pick up, jump in/out)
• Built a solver using breadth-first search that explores all possible action sequences simultaneously, guaranteed to find the shortest solution path
• Fully mapping the state space revealed that even the hardest puzzles are trivially simple when visualized—just path-finding on a tiny graph with ~50 nodes
• The real value wasn't the automated solution—encoding the puzzle forced systematic consideration of every location and transition, revealing the answer before the code finished
• Real problems aren't finite state machines, but the lesson holds: rigorous problem decomposition forces you to examine details your brain wants to ignore
In Detail
The author got stuck on a puzzle in Cocoon, a video game where you play as a bee navigating abstract worlds using orbs that contain other worlds you can jump in and out of. Rather than look up the solution, he decided to write a program to solve it—arguing this doesn't count as cheating since building the solver would be more fun and educational.
The key insight is that Cocoon's puzzles can be modeled as finite state machines. Unlike most 3D games with near-infinite possible states, Cocoon has discrete, countable states defined by your location, which orb you're holding, and where the other orbs are. Transitions between states are limited to simple actions like walking to adjacent nodes, picking up/putting down orbs, or jumping in/out of orb-worlds. This makes it possible to build a simplified programmatic version of the game that captures all its logic without the graphics. The author then used breadth-first search (BFS) to find solutions—the algorithm simultaneously explores every possible action sequence, stepping through all paths at once until one reaches the goal state, guaranteeing the shortest solution.
The most revealing part came when he fully mapped out the puzzle's entire state space. Even the hardest puzzle—which requires counter-intuitive strategies like nesting orbs inside each other in specific orders—reduces to a simple graph with about 50 nodes. It's just "find a path from the green dot to one of the red dots," solvable by a toddler. Writing everything down strips away the misleading heuristics that make humans focus on some strategies while completely missing others. But the real lesson wasn't about automated solving—the act of encoding the puzzle forced him to systematically consider every location and transition, including ones the game had tricked him into ignoring. This rigorous attention actually revealed the solutions before he finished programming them. While real life isn't a finite state machine, the principle holds: systematic decomposition forces you to examine the details your intuition wants to skip.