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.2.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.2-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: minesweeper_cli-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 c17570d4b1ea221a9e8e8f906f345e7d8110ba3327338fdeaad2c3ada45ddbb2
MD5 7d003b8da3a33ff5b127f23370406651
BLAKE2b-256 1563a5f57742b0e44d7a8f1d59397c337202d4419b81c71328be6b449f1d3366

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for minesweeper_cli-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b78b6eccba0957b862e353065bfc4cf05410efee0d451793661f1e241426d013
MD5 f60ca9793209b00106a1cd9c1be66186
BLAKE2b-256 562fc5144db5bf9c499355bd0c34ded8d5dfaf6631f38f077b5ff83c773b00c1

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