A CLI version of the populadr "Minesweeper" game, written in Python. This project demonstrates core software engineering principles, including object-oriented design, algorithmic thinking, and a clean separation of concerns.
- Object-Oriented Design: The entire game is encapsulated within a Board class, which manages all game state, logic, and data.
- Recursive Algorithm: Uses a recursive algorithm (dig method) to reveal adjacent empty squares.
- Clean User Interface: A user-friendly and playable command-line interface with input validation and visual feedback.
- Multiple Difficulty Levels: Includes "Easy," "Medium," and "Hard" settings, adjusting the board size and number of bombs accordingly.
- Make sure you have Python 3 installed.
- Launch the Game: Run the main script from your terminal:
python main.py
- Choose Difficutly: You will be prompted to select your difficulty level.
- Enter Coordinates: To reveal a square, enter the row and column number, separated by a comma (e.g., 4,5).
- The board is printed with row and columns headers to guide you.
- Win or Lose:
- You win by revealing every square that is not a bomb.
- You lose if you reveal a square that contains a bomb, in which case all bomb locations will be revealed.
The goal of this project was to showcase a strong understanding of core programming concepts.
- Class-Based Design: The Board class is entirely self-contained. It handles board generation, bomb placement, neighbor calculation, and win/loss state, making the main game loop clean and simple.
- Efficient Data-Structure: set() is used for tracking already revealed squares and bomb locations, while dict() is used for tracking adjacent cells. This makes loop up operations highly efficient.
- Separation of Concerns: The main script (main.py) is responsible only for user interacion and input validation, while classes.py handles all the complex game logic. The goal of this separation is to make the code easier to maintain, debug, and understand.