Mathematical models and interactive solvers for Prince of Persia speedrun puzzles
A suite of state-space simulators and search algorithms created to find the absolute minimum input sequences for Prince of Persia speedruns. Play with the interactive models below or explore the underlying state machines.
In The Two Thrones, the Prince must navigate a giant statue of his father King Sharaman through the palace courtyard. Each tile on the courtyard track permits specific movements (forward/backward translation or clockwise/anti-clockwise rotation) depending on track orientation.
The Water Pillar puzzle features stacked rotating tiers (Lower, Middle, Upper, and Joint valves) that turn water conduits to open locked watergates. Specific cranks turn all rings synchronously, while others manipulate differential gears.
A dual interlocking rotary ring puzzle from the Wii version of The Forgotten Sands. Rotating the Left or Right dials cycles gem arrays c1 and c2 around their intersection point.
In speedruns, solving puzzles by intuition or standard intended player routes wastes dozens of seconds. Because each move has a deterministic transition matrix, we can model the entire game puzzle as a directed graph and compute the Breadth-First Search (BFS) shortest path to discover the fastest possible inputs.
The King's Statue puzzle uses a 2D transition table indexed by [rotation][translation]. Certain tiles block forward motion if the statue is facing the walls or dead ends. The C++ simulator validates each candidate move string in sub-microsecond time.
The Forgotten Sands puzzles involve coupled modulo arithmetic (e.g. cw(piece) = (piece == 4) ? 1 : piece + 1). Nested for-loops cycle through permutations to verify the minimum move sequence that solves all alignment constraints simultaneously.