This project provides a professional automation solver for the classic Minesweeper game using Selenium. The solver interacts with the Minesweeper game on a webpage, extracts the game grid, and employs a strategic approach to solve the puzzle.
Before starting, ensure the following requirements are met:
- Python 3.x 🐍: Programming language used for the project.
- Selenium 🌐: Library for browser automation.
- ChromeDriver 🖥️: WebDriver for Google Chrome.
-
Clone the Repository
git clone https://github.com/yourusername/minesweeper-solver.git cd minesweeper-solver
-
Install Dependencies Install the required Python libraries:
pip install selenium
-
Set Up ChromeDriver
- Download ChromeDriver from the official site.
- Place the downloaded
chromedriver
executable in the project directory.
-
Configure the Script
- Open the
minesweeper.py
file. - Update the
executable_path
in theService
object to point to yourchromedriver
file.
- Open the
-
Run the Solver Execute the script in your terminal:
python minesweeper.py
-
Observe the Automation
- The script will open a browser, navigate to the Minesweeper game webpage, and attempt to solve the puzzle using its automated strategy.
- Navigate to the Game: Opens the Minesweeper game webpage in a browser.
- Extract the Game Grid: Reads the current state of the Minesweeper grid.
- Apply the Solving Strategy: Uses logical techniques to identify safe cells to open or flag as mines.
- Interact with the Game: Simulates mouse clicks and flags cells based on solver decisions.
GetID(first, second)
: Returns the cell ID based on row and column coordinates.define(i, j)
: Identifies the state of a cell (open, flagged, or closed).fill()
: Populates the path list with cell coordinates.Situation()
: Evaluates the game state (win, lose, or ongoing).GetJ(Worde)
: Extracts the column index from a coordinate string.GetI(Worde)
: Extracts the row index from a coordinate string.DeleteItem(i)
: Removes an item from the path list if all surrounding cells are open or flagged.check(i, j, num)
: Validates and clicks cells based on the number of surrounding mines.newTable(table)
: Generates a new table of cell IDs.method()
: Implements the primary logic to solve the Minesweeper game.
We welcome contributions to enhance this project! If you find bugs, have feature suggestions, or would like to add improvements, feel free to:
- Open an Issue: Describe the problem or suggestion.
- Submit a Pull Request: Propose your changes with proper documentation and testing.
This project is licensed under the MIT License. Feel free to use, modify, and distribute this project within the terms of the license.
Thank you for checking out this project! 🚀