Mine-Streaker is a Python research codebase that reconstructs Minesweeper mine layouts from source images. The objective is dual:
- visual fidelity to the source image
- deterministic solver reachability (low or zero unresolved safe cells)
Primary workflows:
run_iter9.pyfor single image reconstructionrun_benchmark.pyfor benchmark matrices and regression-only checks
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install numpy scipy numba Pillow matplotlib scikit-imagepython run_iter9.py --help
python run_benchmark.py --helppython assets/image_guard.py --path assets/line_art_irl_11_v2.png --allow-noncanonicalpython run_iter9.py --image assets/line_art_irl_11_v2.png --allow-noncanonicalFor multi-image Iter9 experiments, use native image-sweep mode instead of shell-looping --image once per file.
python run_benchmark.py --image assets/line_art_irl_11_v2.png --widths 300 360 420 --seeds 300 301 302 --allow-noncanonicalpython run_benchmark.py --regression-onlyThe gameworks/ package is a Pygame-based interactive Minesweeper that can use pipeline output boards.
pip install pygame scipy numpyClassic random board:
python -m gameworks.main --random --easy
python -m gameworks.main --random --medium
python -m gameworks.main --random --hardLoad a pre-built pipeline board (recommended for development):
# Load a board from a previous pipeline run
python -m gameworks.main --load results/iter9/<run_id>/grid_iter9_300x300.npy
# Custom board size
python -m gameworks.main --load path/to/board.npy --seed 42Image-reveal mode (runs the pipeline at launch — slow, requires Numba warmup):
python -m gameworks.main --image assets/tessa_line_art_stiletto.png --board-w 300| Input | Action |
|---|---|
| Left-click | Reveal tile |
| Right-click | Flag / unflag |
| Middle-click or Ctrl+Left | Chord (reveal neighbours) |
| Scroll wheel | Zoom in/out |
| Mouse drag | Pan board |
| Arrow keys | Pan board |
| R | Restart game |
| H | Toggle help overlay |
| F | Toggle fog of war |
| ESC | Quit |
# Full gameworks suite (headless — no display required for renderer tests)
SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy pytest gameworks/tests/ -v
# Legacy regression guard (root suite)
SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy pytest tests/test_gameworks_engine.py tests/test_gameworks_renderer_headless.py -vNormal runs are CLI image driven (--image).
Validation model:
- default image with default manifest
- explicit image with explicit manifest
- explicit image with
--allow-noncanonical(warning mode)
Entrypoint flags:
run_iter9.py:--image,--out-dir,--board-w,--seed,--allow-noncanonical,--image-manifest,--run-tagrun_benchmark.py:--image,--widths,--seeds,--out-dir,--allow-noncanonical,--image-manifest,--regression-only,--include-regressions
Batch-image guidance:
- For native multi-image Iter9 runs, use
run_iter9.py --image-dir ... --image-glob .... - Do not use a shell loop over
run_iter9.py --image ...for batches that image-sweep mode can express directly.
.
|-- AGENTS.md
|-- CLAUDE.md
|-- README.md
|-- board_sizing.py
|-- core.py
|-- corridors.py
|-- pipeline.py
|-- repair.py
|-- report.py
|-- run_iter9.py
|-- run_benchmark.py
|-- sa.py
|-- solver.py
|-- source_config.py
|-- assets/
|-- configs/
|-- docs/ # Pipeline and governance docs
|-- gameworks/ # Interactive Pygame Minesweeper game
| |-- engine.py
| |-- renderer.py
| |-- main.py
| |-- docs/
| `-- tests/
|-- tests/ # Root test suite (pipeline + gameworks legacy)
`-- results/
run_iter9.py and benchmark child runs use this sequence:
- Resolve source config and validate image integrity.
- Derive board height from source-image aspect ratio (
board_sizing.py). - Build target field and zone-aware weights (
core.py). - Build adaptive corridors (
corridors.py). - Run coarse/fine/refine SA (
sa.py). - Run deterministic solver (
solver.py). - Run Phase 1 repair (
repair.py). - Route late-stage unresolved failures (
pipeline.py) through phase2/last100 logic when appropriate. - Render technical and explained reports (
report.py). - Persist metrics/artifacts under
results/.
metrics_iter9_<board>.jsongrid_iter9_<board>.npygrid_iter9_latest.npyiter9_<board>_FINAL.pngiter9_<board>_FINAL_explained.pngrepair_overlay_<board>.pngrepair_overlay_<board>_explained.pngfailure_taxonomy.jsonrepair_route_decision.jsonvisual_delta_summary.json
- child dirs named
<board_width>x<board_height>_seed<seed>/ - benchmark summaries:
benchmark_summary.jsonbenchmark_summary.csvbenchmark_summary.mdbenchmark_results.json
- summary rows expose
phase1_repair_hit_time_budget,phase2_full_repair_hit_time_budget, andlast100_repair_hit_time_budget; board aggregates include per-phase timeout counts andany_repair_timeout
Technical PNGs are detailed audit/debug artifacts. Explained PNGs are beginner-readable first-look artifacts and do not replace technical artifacts.
Use image-sweep mode to run Iter9 across discovered images in one batch.
python run_iter9.py --image-dir assets --image-glob "*.png" --board-w 300 --seed 11 --allow-noncanonical --run-tag "assets_smoke_top2_w300_s11" --out-root "results/iter9/sweep_assets_smoke_top2_w300_s11" --max-images 2Filtered research-image sweep:
foreach ($seed in 11,12,13) { python run_iter9.py --image-dir assets --image-glob "input_source_image_research_irl[1-9].png" --board-w 300 --seed $seed --allow-noncanonical --run-tag "research_irl1_9_w300_s$seed" --out-root "results/iter9/sweep_research_irl1_9_w300_s$seed" }Core sweep flags:
--image-diractivates sweep mode.--image-globselects files (default*.png).--recursiveincludes nested folders.--out-rootsets the batch root. If omitted, output defaults toresults/iter9/<batch_id>/.--continue-on-errorkeeps processing after failed child runs.--skip-existingskips children when expected metrics already exist.--max-imageslimits discovered files after sorting.
Batch root outputs:
iter9_image_sweep_summary.jsoniter9_image_sweep_summary.csviter9_image_sweep_summary.md
Per-child metrics behavior:
- Single-image runs include top-level
source_image_validationand omitbatch_context. - Sweep child runs include top-level
source_image_validationand populatedbatch_context.
Required explained labels include:
Target value: 0 background -> 8 strongest lineGenerated number: 0 no nearby mines -> 8 surroundedDifference: 0 match -> 4+ large mismatchVisual change: negative better -> positive worse
Explained optimization chart must use:
- title:
Optimizer progress: lower is better - x-axis text including
Optimizer work, in millions of attempted mine changesand1 plotted point = 50,000 attempted changes - y-axis:
Match error score (lower is better)
Technical report wording remains:
Loss curve (log)x50k itersWeighted loss
Default test suite:
python -m unittest discover -s tests -p "test_*.py"Contract-focused tests include:
tests/test_source_image_cli_contract.pytests/test_benchmark_layout.pytests/test_report_explanations.pytests/test_repair_route_decision.pytests/test_route_artifact_metadata.pytests/test_solver_failure_taxonomy.py
- Keep generated artifacts under
results/. - Keep ownership boundaries:
solver.py: unresolved-cell classificationpipeline.py: route selection and route artifactsrepair.py: repair mutations and move logsreport.py: visual proof artifactssa.py: optimization kernel only, no repair routing logic
Use docs/DOCS_INDEX.md to determine active vs archived docs before editing.