Skip to content

richiedlrsa/minesweeper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Minesweeper

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.

Key Features

  • 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.

How to Play

  1. Make sure you have Python 3 installed.
  2. Launch the Game: Run the main script from your terminal:
python main.py
  1. Choose Difficutly: You will be prompted to select your difficulty level.
  2. 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.
  3. 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.

Technical Deep Dive

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.

About

A CLI version of the popular "Minesweeper" game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages