A Python simulation of the 100 prisoners problem, where each prisoner must find their own number hidden in one of 100 boxes.
This project allows you to run multiple simulations using custom strategies, view success rates, and manage runs through a clean working directory system.
If you have any questions or suggestions, feel free to open an issue or submit a pull request! It would make my day. 😊
- Run a predefined number of simulations automatically
- Use custom strategies for box selection
- Customize the number of prisoners and maximum box checks
- Calculate and display:
- Overall chance of success
- Average number of checked boxes per prisoner
- Percentage of finds per prisoner
- Built-in directory management for saving results and configurations
I created this simulator because I wanted a way to easily prove the math behind the 100 prisoners problem, and to experiment with different strategies that people have come up with, maybe even stumble upon a new, better one. 😉
The 100 prisoners problem is a classic probability and logic puzzle. Each prisoner may open up to half the boxes (50) to find their number.
If all prisoners succeed, they are freed; if even one fails, they all lose.
A clear video explanation of the 100 prisoners problem and the best strategy so far (cycle following) can be found here: https://youtu.be/iSNsgj1OCLA?si=Bgq4OAlChz_tSI_g
- Download the latest release
- Unzip the downloaded .zip file
- Create a working directory in the root folder (e.g., "Prisoners-Riddle/experiments/test1")
- Copy the config.py file to your working directory and configure your strategy and other parameters inside the config file
- Run the main Python file:
python main.py
MIT License - feel free to contribute or share it.
See LICENSE.md for details.
- Better GUI
- Seed customizability
- Parallelized simulations for faster results