Skip to main content

Classic Minesweeper game for the terminal with colorful CLI interface

Project description

Minesweeper CLI ๐Ÿ’ฃ

Classic Minesweeper game for the terminal, built with Python. Features colorful interface, multiple difficulty levels, and intuitive commands.

๐ŸŽฎ Game Preview

    A  B  C  D  E  F  G  H
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
1 โ”‚ โฌ› โฌ› โฌ› โฌ› โฌ› โฌ› โฌ› โฌ› โ”‚
2 โ”‚ ยท  1  1  2  โฌ› โฌ› โฌ› โฌ› โ”‚
3 โ”‚ ยท  1  ๐Ÿšฉ 2  โฌ› โฌ› โฌ› โฌ› โ”‚
4 โ”‚ ยท  1  1  2  โฌ› โฌ› โฌ› โฌ› โ”‚
5 โ”‚ ยท  ยท  ยท  1  โฌ› โฌ› โฌ› โฌ› โ”‚
6 โ”‚ 1  1  ยท  ยท  โฌ› โฌ› โฌ› โฌ› โ”‚
7 โ”‚ โฌ› 1  ยท  ยท  โฌ› โฌ› โฌ› โฌ› โ”‚
8 โ”‚ โฌ› 1  ยท  ยท  โฌ› โฌ› โฌ› โฌ› โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Banderas: 1/10  Tiempo: 2:34

> reveal D5

๐Ÿš€ Installation

Use uv

uv tool install minesweeper-cli

๐ŸŽฏ Usage

Basic Commands

# Run with default easy level
minesweeper

# Run with specific difficulty
minesweeper --level medium
minesweeper --level hard

# Show version
minesweeper --version

# Show help
minesweeper --help

Difficulty Levels

Level Grid Size Mines Description
Easy 8ร—8 10 Perfect for beginners
Medium 16ร—16 40 Balanced challenge
Hard 30ร—16 99 Expert level

๐ŸŽฎ How to Play

In-Game Commands

Command Aliases Example Description
reveal <coord> r <coord> reveal A1 Reveal a cell
flag <coord> f <coord> flag B3 Place/remove flag
help h, ? help Show help screen
quit q quit Exit game
new n new New game (end game only)

Coordinate System

  • Columns: Letters (A-Z, then AA-AZ, BA-BZ, etc.)
  • Rows: Numbers (1, 2, 3, ...)
  • Format: Letter + Number

Examples: A1, B3, AA15, AD30

Game Symbols

Symbol Meaning Color
โฌ› Unrevealed cell Blue
ยท Empty revealed cell White
๐Ÿšฉ Flag -
๐Ÿ’ฅ Exploded mine -
๐Ÿ’ฃ Mine (shown when game ends) Red
1-8 Adjacent mine count Various*

*Number colors: 1=Cyan, 2=Green, 3=Yellow, 4=Magenta, 5=Red, 6=Cyan, 7=White, 8=Red

Gameplay Rules

  1. Goal: Reveal all cells that don't contain mines
  2. Numbers: Show how many mines are adjacent to that cell
  3. Flags: Use to mark suspected mine locations
  4. Cascade: Empty cells automatically reveal adjacent empty areas
  5. Game Over: Revealing a mine ends the game
  6. Victory: Reveal all non-mine cells to win

๐Ÿ“‹ Game Examples

Easy Game Session

    A  B  C  D  E  F  G  H
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
1 โ”‚ 1  1  ยท  ยท  ยท  ยท  1  โฌ› โ”‚
2 โ”‚ ๐Ÿ’ฃ 1  ยท  ยท  ยท  ยท  1  โฌ› โ”‚
3 โ”‚ 1  1  ยท  ยท  ยท  ยท  1  โฌ› โ”‚
4 โ”‚ ยท  ยท  ยท  ยท  ยท  ยท  1  โฌ› โ”‚
5 โ”‚ ยท  ยท  ยท  ยท  ยท  ยท  1  โฌ› โ”‚
6 โ”‚ ยท  ยท  ยท  ยท  ยท  ยท  1  โฌ› โ”‚
7 โ”‚ 1  1  1  1  1  1  2  โฌ› โ”‚
8 โ”‚ โฌ› โฌ› โฌ› โฌ› โฌ› โฌ› โฌ› โฌ›โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

ยกBOOM! 
Pisaste una mina en A2

Banderas encontradas: 0/10
Tiempo total: 1:23

[N]ueva partida
[S]alir

Victory Screen

ยกGANASTE! ๐ŸŽ‰

Todas las minas encontradas
Tiempo: 5:23

[N]ueva partida
[S]alir

๐Ÿ› ๏ธ Development

Setup Development Environment

# Clone repository
git clone <repository-url>
cd minesweeper-cli

# Setup with uv (recommended)
uv venv
source .venv/bin/activate
uv pip install -e .

# Or setup with pip
python -m venv .venv
source .venv/bin/activate
pip install -e .

Install using uv (recommended)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create virtual environment and install
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e .

Using pip

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
pip install -e .

Run Tests

# When tests are implemented
uv run pytest tests/

# Code quality checks
uv run ruff src/ --check
uv run black src/ --check
uv run mypy src/

Project Structure

minesweeper-cli/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ minesweeper/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ main.py          # CLI entry point and main game loop
โ”‚       โ”œโ”€โ”€ game.py          # Game logic and state management
โ”‚       โ”œโ”€โ”€ models.py        # Data structures (Cell, Board, GameState)
โ”‚       โ”œโ”€โ”€ renderer.py      # Display and visualization
โ”‚       โ””โ”€โ”€ commands.py      # Command parsing and validation
โ”œโ”€โ”€ examples/
โ”‚   โ””โ”€โ”€ play_example.py      # Programmatic usage examples
โ”œโ”€โ”€ tests/                   # Test files (to be implemented)
โ”œโ”€โ”€ docs/                    # Design documents
โ”œโ”€โ”€ pyproject.toml          # Project configuration
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ LICENSE                 # GPLv3 License

๐Ÿงฉ Examples

See examples/play_example.py for programmatic usage:

python examples/play_example.py

This shows how to:

  • Create games programmatically
  • Make automated moves
  • Integrate game logic into other applications

๐Ÿ”ง Requirements

  • Python 3.9 or higher
  • Click 8.0+ (CLI framework)
  • Colorama 0.4+ (terminal colors)

๐Ÿ“œ License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Current Features โœ…

  • Three difficulty levels (Easy, Medium, Hard)
  • Colorful terminal interface
  • Intuitive command system
  • Flag placement and removal
  • Cascade reveal for empty areas
  • Win/lose detection
  • Game timer
  • Cross-platform support

Future Enhancements ๐Ÿš€

  • Improvements on UX (revealing a number should auto-reveal adjacent free cells and other numbers)
  • Save/load game state
  • Statistics and best times
  • Custom difficulty levels
  • Hint system

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the in-game help: help command
  2. Review this README
  3. Check the examples in examples/
  4. Open an issue on Gitlab

Happy Minesweeping! ๐Ÿ’ฃ๐ŸŽฎ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minesweeper_cli-1.0.3.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minesweeper_cli-1.0.3-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file minesweeper_cli-1.0.3.tar.gz.

File metadata

  • Download URL: minesweeper_cli-1.0.3.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for minesweeper_cli-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9b44f4c05c207af88cba61293174f983d9185e5b9ba0c200745221cc03030d0a
MD5 f9fc99e03bfbe787204013ccc9d8b6cb
BLAKE2b-256 989e9b432e7119d6d268c23ad9b2036090ee5b85a09b799baf110ec878987dd1

See more details on using hashes here.

File details

Details for the file minesweeper_cli-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for minesweeper_cli-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1f415025adeb3be60e0622ba0aadbfb25d6b68d875387e138077953a73b20e30
MD5 9d9235e1034b4a823a65072c9172eeca
BLAKE2b-256 c1f565850d45587afae7739450210362f765a68f6b891ab96f32513b7f4e6019

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page