01 / OVERVIEW
A probability puzzle you can play.
The Box Ward is an animated web adaptation of the 100 Prisoners and 100 Boxes puzzle. It includes a single-player puzzle game and a Strategy Lab for comparing random searching with the cycle-following strategy.
02 / APP MODES
Explore the puzzle, then investigate the strategy.
Classic Mode
Each round assigns a target from 1 to 100, distributes the numbers across 100 boxes, and gives the player up to 50 attempts to find the target.
Strategy Lab
Explore permutation cycles, follow a path step by step, and compare observed group success rates across configurable simulation sizes.
03 / ALGORITHM
Cycle-following turns search into a path.
- A prisoner starts by opening the box with their own number.
- The number revealed inside identifies the next box to open.
- The prisoner follows that chain for up to 50 attempts.
- The group succeeds when every permutation cycle has a length of 50 or less.
The project implements permutation cycle decomposition and a Fisher-Yates shuffle. The Strategy Lab provides an interactive cycle walkthrough and a cycle-length analysis.
04 / SIMULATION
Simulated results against the theory.
The Monte Carlo simulator compares random search and cycle-following across 100, 1,000, or 10,000 rounds. The repository README describes the cycle-following theoretical group success probability as approximately 31.18%, compared with 2-100 (approximately 7.89 × 10-31) for independent random searching under the puzzle assumptions.
These figures describe the mathematical model and simulation feature, not a measured real-world outcome.
05 / ENGINEERING
Keep deterministic logic separate and testable.
The project uses Next.js App Router, React components, JavaScript logic modules, CSS animations, and Node.js unit tests. Puzzle rules and strategy calculations are separated into logic modules so the application behavior can be tested independently of the interface.
06 / LIMITATIONS
The adaptation is not the original puzzle.
The README states that Classic Mode is a single-player adaptation: boxes remain open during the player’s round. In the original puzzle, prisoners cannot see boxes opened by earlier prisoners. The project notes this difference rather than presenting the game as a full simulation of the original multi-prisoner process.