Skip to content

SM1LE666/minesweeper-kivy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Minesweeper Kivy

A modern implementation of the classic Minesweeper game built with Python and Kivy framework, following SOLID design principles for clean, maintainable code.

Python Kivy License

๐ŸŽฎ About

This Minesweeper implementation features a clean, modern interface with emoji support and follows object-oriented design patterns. The game provides an engaging experience with smooth gameplay, visual feedback, and customizable difficulty levels.

โœจ Features

Core Gameplay

  • Smart Mine Generation: Mines are placed after the first click to ensure a fair start
  • Intelligent Cell Revealing: Automatically reveals adjacent empty cells
  • Flag System: Right-click to mark suspected mines
  • Win/Loss Detection: Clear victory and defeat conditions
  • Game Reset: Quick restart functionality

Visual Features

  • Emoji Support: Modern emoji-based mine and flag indicators (๐Ÿ’ฃ๐Ÿšฉ)
  • Color-Coded Numbers: Each number has a distinct color for easy recognition
  • Clean UI: Minimalist design with clear cell states
  • Alternative Themes: Switch between emoji and text-based renderers
  • Responsive Layout: Adapts to different window sizes

Technical Features

  • SOLID Architecture: Clean separation of concerns with MVC pattern
  • Observer Pattern: Real-time UI updates based on game state changes
  • Strategy Pattern: Pluggable cell rendering systems
  • Interface-Based Design: Easy to extend and modify
  • Type Hints: Full type annotation for better code maintainability

๐Ÿ—๏ธ Architecture

The project follows SOLID principles with a clear separation of concerns:

โ”œโ”€โ”€ models/           # Game logic and state management
โ”œโ”€โ”€ views/            # UI components and rendering
โ”œโ”€โ”€ controllers/      # Input handling and coordination
โ”œโ”€โ”€ interfaces/       # Abstract interfaces and contracts
โ””โ”€โ”€ utils/            # Utility classes and helpers

Key Components

  • MinesweeperModel: Core game logic, mine placement, and state management
  • MinesweeperView: Kivy-based UI with customizable cell rendering
  • MinesweeperController: Coordinates between model and view, handles user input
  • Cell Renderers: Pluggable rendering strategies (Default/Minimalist themes)

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.7 or higher
  • Kivy framework

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd minesweeper-kivy
  2. Install dependencies:

    pip install kivy
  3. Run the game:

    python main.py

๐ŸŽฏ How to Play

Controls

  • Left Click: Reveal a cell
  • Right Click: Toggle flag on a cell
  • Reset Button: Start a new game

Objective

Clear all cells that don't contain mines. Numbers indicate how many mines are adjacent to that cell.

Game Rules

  1. Click on cells to reveal them
  2. Numbers show adjacent mine count
  3. Use flags to mark suspected mines
  4. Avoid clicking on mines
  5. Win by revealing all safe cells

โš™๏ธ Configuration

Default Settings

  • Grid Size: 15ร—15 cells
  • Mine Count: 30 mines
  • Renderer: Emoji-based (DefaultCellRenderer)

Customization

You can customize the game by modifying main.py:

# Create custom game configuration
app = create_minesweeper_app(
    rows=20,           # Grid height
    cols=20,           # Grid width
    mine_count=50,     # Number of mines
    use_minimalist_renderer=True  # Text-based theme
)

Available Renderers

  • DefaultCellRenderer: Modern emoji-based interface (๐Ÿ’ฃ๐Ÿšฉ)
  • MinimalistCellRenderer: Text-based interface (M/F/X)

๐Ÿ› ๏ธ Development

Project Structure

minesweeper-kivy/
โ”œโ”€โ”€ main.py                 # Application entry point
โ”œโ”€โ”€ game.py                 # Legacy game logic (for reference)
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ minesweeper_model.py    # Core game logic
โ”œโ”€โ”€ views/
โ”‚   โ””โ”€โ”€ game_view.py            # UI components
โ”œโ”€โ”€ controllers/
โ”‚   โ””โ”€โ”€ game_controller.py      # Input handling
โ”œโ”€โ”€ interfaces/
โ”‚   โ””โ”€โ”€ game_interfaces.py      # Abstract interfaces
โ””โ”€โ”€ utils/
    โ””โ”€โ”€ cell_renderers.py       # Rendering strategies

Design Patterns Used

  • Model-View-Controller (MVC): Clear separation of concerns
  • Observer Pattern: Model notifies view of changes
  • Strategy Pattern: Pluggable cell renderers
  • Dependency Injection: Loose coupling between components
  • Interface Segregation: Small, focused interfaces

Running Tests

# Add your test commands here when tests are implemented
python -m pytest tests/

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Use type hints for all functions
  • Document classes and methods
  • Follow SOLID principles

๐Ÿ“ธ Screenshots

Add screenshots of your game in action here

๐Ÿ”ง Troubleshooting

Common Issues

Game doesn't start:

  • Ensure Python 3.7+ is installed
  • Verify Kivy installation: pip show kivy

No emoji display:

  • Check if emoji font is available on your system
  • Switch to minimalist renderer if needed

Performance issues:

  • Try reducing grid size for older hardware
  • Use minimalist renderer for better performance

๐Ÿ—บ๏ธ Roadmap

  • Difficulty presets (Beginner, Intermediate, Expert)
  • High score tracking
  • Timer functionality
  • Sound effects
  • Custom themes
  • Multiplayer support
  • Mobile touch optimization

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Kivy team for the excellent framework
  • Classic Minesweeper for the timeless gameplay
  • Python community for design pattern inspiration

Enjoy the game! ๐Ÿ’ฃ

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages