Speedrun Optimization · Algorithmic Bruteforce

Prince of Persia Puzzle Simulators

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.

Select a Puzzle Simulator

Prince of Persia: The Two Thrones · T2TKINGP.CPP

King's Statue Puzzle Simulator

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.

Track Progress (0 → 5):
Start (0)
1
2
3
4
Goal (5)
Translational Step: 0
Facing Heading: Front
Total Moves: 0
Available Moves from this Tile:
Move History:
No moves made yet
Prince of Persia: The Forgotten Sands · TFS_WaterPillar3.CPP

Water Pillar 3 Puzzle Simulator

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.

Upper Tier:
2
Middle Tier:
4
Lower Tier:
1
Rotate Levers:
Move History:
No moves made yet
The Forgotten Sands (Wii) · TFS_Wii_Gems_Simulator.CPP

Dual-Gear Gems Puzzle Simulator

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.

Left Ring Slots (c1)

Right Ring Slots (c2)

Dial Rotations:
Move History:
No moves made yet

Speedrun Bruteforce Architecture

STATE SPACE MAPPING

Why Bruteforce?

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.

T2T STATUE CONSTRAINTS

The Two Thrones Matrix

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.

TFS PERMUTATIONS

Differential Gear Rings

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.