Coder Social home page Coder Social logo

minesweeper-solver-rust's Introduction

demo gif

  • This project solves minesweeper.
  • It has a 42% win-rate.
  • It can simulate a full game in 1 ms on a single core and can run a simulation on each core simultaneously. Caching, avoiding heap allocations, and other optimizations are used to bring the time this low.
  • The speed of the solver when playing a real game using screen capture is entirely dependent on how fast your computer can capture frames as they render. Multiple actions are queued at a time so less screen captures are needed.
  • The algorithm works as follows:
    1. First solve all obvious deterministic methods.
    2. Next try local solving in which mines are placed in possible positions for a numbered cell, and it is determined if any mine is obviously wrong or right.
    3. Then use a probabilistic guess algorithm to enumerate every possible position of mines on the board of visible cells and choose the least likely position to be a mine.
    4. When the number of cells and mines left is small enough to not go over the max combinations threshold, include all mines left and all cells on the board (not just those that border the explored edge) to increase odds of winning in the endgame by analyzing every possible placement of all remaining mines.
  • It's setup to solve minesweeper from minesweeperonline.com/, however, it can be setup to solve any minesweeper program as long as the .png files are replaced. It's expected that all images for tile/cell types are the same image size and correctly named.
    • If an unidentified tile/cell image is found it will be saved to cell_images/Unidentified.png before the program panics, so only the unexplored cell type image needs to be correct for the program to find the board and attempt solving. The other images can be set by renaming the generated cell_images/Unidentified.png when the computer finds a new cell type image.
    • It is possible the images in the repo won't work for you as the website has multiple possible tile images depending on computer monitor size.
  • In main.rs there are some configuration options.
    • NUMBER_OF_MINES controls how many mines the solver expects there to be. This is 99 for an expert mode game.
  • In lib.rs there are some configuration options.
    • TIMEOUTS_ATTEMPTS_NUM controls how many times the program is willing to re-scan the page for an update. This exists because sometimes the board is screenshotted to be analyzed before the board updates.
    • MAX_COMBINATIONS controls how many combinations the probabilistic guess method is willing to go through before giving up and using a less accurate but quicker guess method instead.

minesweeper-solver-rust's People

Contributors

easyoakland avatar

Watchers

 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.