Minesweeper AI

The model for my implementation of minesweeper AI is based off of the implementation found at: luckytoilet.wordpress.com.

I was recently tasked with writing an AI to solve the classic game Minesweeper. I found a blog post that outlines how someone else has solved this in the past, and in in they state that the key to creating a method to solve games of minesweeper lie in three parts. The three parts are reading the board, calculating the positions of mines, and lastly, clicking. To do each of these three steps, the original poster had used some methods in order to scan the board and read the colors of the tiles in order to make more accurate selections, along with using algorithms to select tiles when their other methods fail.

Since the minesweeper game I am solving is more home brew, I cannot rely on these, methods but some of the logic still applies. In order to solve the  minesweeper game I must first try to clear the board as much as possible. To do this I can use a simple algorithm to select tiles surrounding squares marked empty, and with ones. After some board space is cleared, and I need to worry about mines, I can switch the algorithm to being solving the board as best I can.

In order to solve the game, I need to be able to discern where the mines are based on the numbers available to me. I can ask the tiles what number is on them, and store the section of tiles surrounding a space where a mine might lie in order to perform calculations. Using that data to calculate the probability of a mine being on a specific square for each tile that is not clicked, I can then selecting a tile with the lowest probability, and recalculate. By using the combined information from the revealed tiles i can track down to a degree of accuracy where the mines might be.

Minesweeper AI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s