Quantum Minesweeper is a quantum twist on the classic game of Minesweeper.
Instead of a fixed hidden layout, each cell is a qubit and a mine is the
Z-basis outcome
-
Shared game with multiple runtimes
- TUI powered by Rich
- Server Web UI powered by FastAPI and Uvicorn
- Browser-only PWA powered by Pyodide, with no application server
-
Multiple backends (selected with
--backendorQMS_BACKEND)- PurePy — NumPy stabilizer tableau with no native extension dependency (default for local and static-browser runs, including Pyodide)
- Stim — optional fast C++ stabilizer simulator (default for deployed server runs)
- Qiskit — optional stabilizer simulator via Qiskit
-
Game modes
-
Classical — standard Minesweeper rules with
$|1\rangle$ mines - Identify — identify deterministic mines and explore all safe regions
- Clear — apply gates to drive all mine probabilities to zero
- Sandbox — no win condition; experiment freely with gates
-
Classical — standard Minesweeper rules with
-
Moves
- Classical: Measure (M), Pin (P)
- 1-qubit gates: X, Y, Z, H, S, Sdg, SX, SXdg, SY, SYdg
- 2-qubit gates: CX, CY, CZ, SWAP
# Clone the repository
git clone https://github.com/maiani/quantum-minesweeper.git
cd quantum-minesweeper
# Copy the example settings
cp .env_example .env
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install the package
python -m pip install -U pip
python -m pip install .Configuration is centralized with Pydantic Settings and loaded from environment variables (and .env in dev).
Common flags:
QMS_BACKEND- simulator backend:purepy,stim, orqiskit. Local config defaults topurepy;scripts/deploy.shdefaults deployed server runs tostim.QMS_ENABLE_AUTH- enable HTTP basic authQMS_USER/QMS_PASS- credentials for basic authQMS_ADMIN_PASS- admin dashboard password; leave unset to disable admin routesQMS_ENABLE_HELP- render the in-app Help sidebar toggleQMS_ENABLE_TUTORIAL/QMS_TUTORIAL_URL- show a Tutorial linkQMS_ENABLE_SURVEY/QMS_SURVEY_URL- show a Survey linkQMS_BASE_URLcan be set for absolute paths.
Create a .env from the supplied .env_example in local development.
Launch the text UI:
python -m qminesweeper tuiDefault backend is PurePy. You can also install and select Stim or Qiskit:
python -m qminesweeper tui --backend purepy
python -m pip install ".[stim]"
python -m qminesweeper tui --backend stim
python -m pip install ".[qiskit]"
python -m qminesweeper tui --backend qiskitLaunch the web interface with:
python -m qminesweeper webui --port 8080Then open your browser at: http://127.0.0.1:8080
Local web UI runs use the configured backend, which defaults to PurePy for a
plain install. The Docker/Cloud Run deployment installs the Stim extra and
defaults QMS_BACKEND to Stim unless you override it.
Build a static version that runs the game in-page with Pyodide and the PurePy backend:
pixi run browser
pixi run browser-serveThen open http://127.0.0.1:8000. The static build does
not need FastAPI, a database, or Cloud Run while you play. It saves the current
game in localStorage, so a reload restores the in-progress board. The bundle
also includes a manifest and service worker for installation and offline use
after its initial successful load.
Build and run locally with
pixi run docker-runCreate the reproducible development environment and run the checks through it:
pixi install
pixi run pre-commit install
pixi run checkPixi installs Python, the editable package with all development and optional
simulator dependencies, Node.js, and the SVG tooling used to regenerate PWA
icons. Exact versions are recorded in pixi.lock. pixi run check runs Ruff,
pytest, and syntax checks over every frontend JavaScript file.
If Pixi is unavailable, a conventional editable install remains supported:
pip install -e ".[dev]"
pytest
python -m ruff check qminesweeper tests scriptsThe test suite exercises all installed simulator backends.
Run pixi task list to list all development, packaging, browser, Docker, and
deployment commands. Their implementation remains in Python modules and the
scripts under scripts/.
Project design and active work are documented in
docs/architecture.md and
docs/roadmap.md.
- Classical mode matches standard Minesweeper: mines are fixed
$|1\rangle$ states and clues sum over neighbors. - Quantum modes use stabilizer states:
- Identify: measure to reveal deterministically safe cells.
- Clear: apply gates (and measurements) to drive each cell's Z-basis mine probability to ~0.
The status bar shows the expected number of mines:
where
Use Sandbox to learn gate effects: see how
- Andrea Maiani
- Niklas Engelhardt Önne
- Jason Pye
MIT License.
(c) 2025-2026 Andrea Maiani and contributors.