Minesweeper game written in Python using Tkinter GUI library.
This fork adds a probabilistic AI solver using recursive backtracking.
- /minesweeper.py - The actual python program with the solver
- /images/ - GIF Images ready for usage with Tkinter
- /images/original - Original PNG images made with GraphicsGale
Solver works with two initial rules followed by the probabilistic AI:
- Rule A: If a tile has the same number of adjacent mines as the number of unclicked tiles adjacent to it, then all of those tiles are mines.
- Rule B: If a tile has the same number of adjacent squares that are flags, all of those tiles are safe.
The probabilistic AI is as follows:
- Find all exposed tiles.
- Find all bordered tiles.
- Generate all valid arrangements of mines in the bordered tiles.
- Get the number of mines in each arrangement
- Subtract the number of mines in a given arrangement from the total number of mines, then perform a calculation where we choose the number of mines left from the unbordered tiles. This is the total number of combinations where the mines are present in the given arrangement
- Repeat for all arrangements.
- Assign each cell the number of times it was determined as a mine
- Divide each number in the cell by the total number of arrangements, which is about 2.7 x 10^102
- Multiply result by 100 to get the probability of that cell being a mine.
- Flag all cells with probability of 100, then click on the cell with the lowest probability.