Skip to content

StephenWattam/minesweeper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MineSweeper

Screenshot

This is a quick project I put together in order to build an AI for minesweeper. It's simple and limited, but that makes it a good toy.

Install

pip install .

Play

minesweeper

The win/lose state of the game will be printed as the window closes. This happens so the AI can play without any further interaction.

Buttons:

  • Left mouse button: click on a square
  • Right mouse button: flag a bomb (turns green)
  • any key: run the AI

AI Algorithm

The AI works in a two-stage process:

  1. Account for all known squares deductively, infering the state of unknown squares that border them (deterministic solver);
  2. When all that can be known is known, compute a probability that each square is a bomb, and select the lowest scoring square (heuristic solver)

Though it's impossible to win every game of minesweeper with a random board, this should be an optimal strategy if the probabilities computed in (2) are 'real'. I suspect there's some room for improvement on this front.

About

A simple minesweeper, designed so AI can play it

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages