Git Product home page Git Product logo

minesweeper-probabilistic-solver's Introduction

Python Tkinter Minesweeper

Minesweeper game written in Python using Tkinter GUI library.

This fork adds a probabilistic AI solver using recursive backtracking.

Screenshot on OSX

Contents:

  • /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:

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:

  1. Find all exposed tiles.
  2. Find all bordered tiles.
  3. Generate all valid arrangements of mines in the bordered tiles.
  4. Get the number of mines in each arrangement
  5. 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
  6. Repeat for all arrangements.
  7. Assign each cell the number of times it was determined as a mine
  8. Divide each number in the cell by the total number of arrangements, which is about 2.7 x 10^102
  9. Multiply result by 100 to get the probability of that cell being a mine.
  10. Flag all cells with probability of 100, then click on the cell with the lowest probability.

minesweeper-probabilistic-solver's People

Contributors

ripexz avatar keremenci avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.