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
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 .
For Users (when published to PyPI)
pip install minesweeper-cli
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
- Goal: Reveal all cells that don't contain mines
- Numbers: Show how many mines are adjacent to that cell
- Flags: Use to mark suspected mine locations
- Cascade: Empty cells automatically reveal adjacent empty areas
- Game Over: Revealing a mine ends the game
- 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 .
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 ๐
- Save/load game state
- Statistics and best times
- Custom difficulty levels
- Hint system
- ASCII animations
- Sound effects (terminal beeps)
- Multiplayer mode
- No-guess guaranteed mode
๐ Support
If you encounter any issues or have questions:
- Check the in-game help:
helpcommand - Review this README
- Check the examples in
examples/ - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minesweeper_cli-1.0.1.tar.gz.
File metadata
- Download URL: minesweeper_cli-1.0.1.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49bf466ef1206598ae58e4686a6089ae778cb370efbda111690c94dc5ffddce7
|
|
| MD5 |
d8837c043998b5c861840c10f34e4cd2
|
|
| BLAKE2b-256 |
267cf698693890c3839b44cb5afdc634f920c9b27f79a6ba56680e81bdd40301
|
File details
Details for the file minesweeper_cli-1.0.1-py3-none-any.whl.
File metadata
- Download URL: minesweeper_cli-1.0.1-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94f1e00de95f1d5d8f1ce6bcf0c46f2312efc61bcaf236f39ac7f085c915e7ff
|
|
| MD5 |
973af0abda8cc7266f3040ad1577e62f
|
|
| BLAKE2b-256 |
df833529a155b319ec3acaa785e723f6591d80402fec8c5d813c9aa2517c2025
|