Skip to content

Xiang511/GitHub-Contribution-Minesweeper

Repository files navigation

GitHub Contribution Minesweeper

Minesweeper SVG PRs Stars Language License

SVG

Turn your GitHub contribution heatmap into a Minesweeper board. Low contribution days are more likely to hide mines, active days are usually safer. Includes advanced auto-solver, replay, and exportable animated SVG.

Features

  • Weighted mine placement based on contribution counts (configurable ratio, default 0.1)
  • First click always safe + zero-area flood expansion
  • Advanced solving: basic rules + subset difference inference + small frontier state enumeration + probabilistic lowest-risk guessing
  • Replay with progress bar
  • Export static board SVG and animated replay SVG (looping + speed control 0.25x ~ 32x)
  • Light / Dark themes
  • Original contribution heatmap with month / week labels
  • Strict mode: disable mock fallback if GitHub fetch fails

Usage

  1. Serve the folder with any static server (VS Code Live Server / Five Server etc.). Demo
  2. Enter a GitHub username.
  3. (Optional) Enter a year (e.g. 2024) → uses Jan 1 ~ Dec 31 of that year (normalized); leave empty for trailing 52 weeks.
  4. Adjust mine ratio.
  5. Enable Strict Mode to forbid mock data (fetch failure will error out).
  6. Click Load / Rebuild.
  7. Left click to reveal, right click to flag.
  8. Control buttons:
    • Auto Step: one inference pass
    • Auto Run: repeated basic inference
    • Auto Solve: advanced solver until completion
    • Replay: play back last auto-solve actions (uses speed select)
    • Export Board SVG: current static board
    • Export Replay SVG: animated SVG (loop capable)
  9. Speed select controls both replay pacing and exported animation step duration.

Project Structure

index.html                # UI + controls
svg-creator.js            # Board + animation SVG generation / export
minesweeper-types.js      # Data structures + reveal / flag logic
auto-player.js            # Auto solver, inference, replay action logging
github-integration.js     # Contribution fetch + normalization
contributions-chart.js    # Contribution heatmap rendering

Advanced Animation Options (exportReplayAnimation)

Option Default Description
stepSeconds 1 Seconds per logical step (UI maps speed = 1/stepSeconds)
fadeDuration 0.25 Color / text fade-in duration per step
simultaneousFlood true If true flood reveals appear together; false = staggered
lightenFactor 0.45 Blend factor for revealed safe cells toward theme background (0~1)
loop true Auto replay animation

Solver Logic Summary

  • Basic: if number = flagged → open others; if flagged + hidden = number → flag hidden.
  • Subset Difference: If constraint A ⊆ B and same mine count → (B \ A) safe; if (B.mines - A.mines) = |B \ A| then (B \ A) all mines.
  • Group Enumeration: Merge overlapping constraints, enumerate groups with ≤12 unknowns, count valid assignments for probabilities.
  • Probabilistic Guess: pick cell with lowest mine probability (tie-break: farther from center / random), reducing forced blind luck.

Development Notes

  • Theme + revealed cell blending in svg-creator.js.
  • Solver internals in auto-player.js; you can extend with SAT / ILP or global probability models.

Inspiration / References

License

This project is published under Apache-2.0 license

About

Turn your GitHub contribution heatmap into a Minesweeper board. Includes advanced auto-solver, replay, and exportable animated SVG.

Topics

Resources

License

Stars

Watchers

Forks