Game A.I. – Minesweeper Planning Phase


Another class I’m taking this year is artificial opponents. Our first assignment is to write an AI for minesweeper, and in this post I’ll detail as to how I plan to write the AI. One thing to note is that I’ll never be able to win 100% of the time, so I need to write plans for different situations in order to increase my AI’s chance of winning.

Plan A:

  1. Start the game and choose a random space. (And pray that it uncovers a good amount)
  2. Scan the grid for any numbered spaces.
  3. Once a numbered space is found – check to see how many uncovered spaces surround it. If the amount of uncovered spaces matches the number on the space, we can determine that those spaces are mines.
  4. As a secondary check, if we find a numbered space that already has all its mines marked around it – we can safely say that all other spaces surrounding the original space are safe, so we’ll uncover those.

This plan will safely uncover a good amount of the game board, however, there will be situations in which there will be no clear solutions. That’s why there’s plan b.


Plan A just won’t cut it here :/

Plan B:

  1. Mark of a specific area of the grid, (this will probably be dynamic and determined by how many numbered spaces I have to work with)
  2. Once I have my space, I’ll need to run an algorithm that determines the chances of a space having a mine.
  3. Once I have my list of spaces, I’ll uncover the spot that has the lowest chance of having a mine. (If there are multiple with the same low chance I’ll just choose randomly.
  4. From there, proceed with plan A until the need for plan B arises again.

If I end up having more plans or improvements to the strategies I listed above while actually coding the AI, I’ll be sure to detail them in future blog posts.


Leave a Reply

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

You are commenting using your 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