Questions tagged [minesweeper]

Minesweeper game is an abstract puzzle, quite popular as a target of sample programs in different laguages.

Rules

The object of the game is to clear an abstract minefield without detonating a mine.

The game is played by revealing squares of the grid, typically by clicking them with a mouse. If a square containing a mine is revealed, the player loses the game. Otherwise, a digit is revealed in the square, indicating the number of adjacent squares (typically, out of the possible eight) that contain mines. In typical implementations, if this number is zero then the square appears blank, and the surrounding squares are automatically also revealed. By using logic, the player can in many instances use this information to deduce that certain other squares are mine-free, in which case they may be safely revealed, or mine-filled, in which they can be marked as such (which, in typical implementations, is effected by right-clicking the square and indicated by a flag graphic).

Popularity

The game has been written for many system platforms in use today. Versions of Minesweeper are frequently bundled with operating systems and GUIs, including Minesweeper for OS/2, Minesweeper in Windows, KMines in KDE (Unix-like OSes), Gnomine in GNOME and MineHunt in Palm OS. Apart from the bundled versions, a huge number of clones of all shapes and sizes can be found on the Internet.

Variants

Variants of the basic game generally have differently shaped mine fields in two and three dimensions, or various two-dimensional layouts, such as triangular or hexagonal grids, or possibly more than one mine per cell. For example, X11-based XBomb adds triangular and hexagonal gridsю

Complexity

In 2000, Richard Kaye published a proof that it is NP-complete to determine whether a given grid of uncovered, correctly flagged, and unknown squares, the labels of the foremost also given, has an arrangement of mines for which it is possible within the rules of the game. The argument is constructive, a method to quickly convert any Boolean circuit into such a grid that is possible if and only if the circuit is satisfiable; membership in NP is established by using the arrangement of mines as a certificate. This proof has been disputed, though.


Source: http://en.wikipedia.org/wiki/Minesweeper_(video_game)

410 questions
94
votes
10 answers

How can I find the data structure that represents mine layout of Minesweeper in memory?

I'm trying to learn about reverse engineering, using Minesweeper as a sample application. I've found this MSDN article on a simple WinDbg command that reveals all the mines but it is old, is not explained in any detail and really isn't what I'm…
KingNestor
  • 65,976
  • 51
  • 121
  • 152
30
votes
11 answers

Minesweeper master from Google Code Jam(2014) Qualification round

This is a problem from Google Code Jam qualification round (which is over now). How to solve this problem? Note: If you have a different method from the ones discussed in answers, please share it so we can expand our knowledge of the different ways…
Joshua Kissoon
  • 3,269
  • 6
  • 32
  • 58
28
votes
4 answers

Generate a minesweeper board which doesn't need guessing

I am designing a Minesweeper-like game (with modified rules), and I want to prevent player from guessing. My goal is: The generated board is with few revealed squares, and player can solve the entire puzzle without any guessing. Wikipedia…
miaout17
  • 4,715
  • 2
  • 26
  • 32
28
votes
8 answers

Minesweeper solving algorithm

I am pretty sure most of you know about the minesweeper game. I wanted to code (in C#) my own minesweeper game and was looking for some input as to what would be a good algorithm for that game? I have been browsing over the web for quite some time…
Saurabh Lalwani
  • 705
  • 2
  • 7
  • 15
19
votes
4 answers

What's the algorithm behind minesweeper generation

Well I have been through many sites teaching on how to solve it, but was wondering how to create it. I am not interested much in the coding aspects of it, but wanted to know more on the algorithms behind it. For example, when the grid is generated…
Rahul
  • 11,129
  • 17
  • 63
  • 76
14
votes
2 answers

Improving my Minesweeper solving algorithm

I have implemented in Python an algorithm for solving the game 'Minesweeper'. The program works as follows: Say that the solver clicks a square named 'a'. For sake of example let the number thus revealed equal 2. The neighbours of the square which…
user1502040
  • 451
  • 3
  • 13
13
votes
1 answer

How to structure a program to work with minesweeper configurations

EDIT: This was a while ago and I've since got it working, if you'd like to see the code it's included at github.com/LewisGaul/minegaulerQt. I'm trying to write a program to calculate probabilities for the game minesweeper, and have had some…
Siwel
  • 705
  • 10
  • 25
8
votes
2 answers

AI Minesweeper project

I need to implement Minesweeper solver. I have started to implement rule based agent. I have implemented certain rules. I have a heuristic function for choosing best matching rule for current cell (with info about surrounding cells) being treated.…
Nikita
  • 1,811
  • 1
  • 20
  • 41
6
votes
1 answer

Minesweeper discovering blank squares

I am trying to make minesweeper in JavaScript and I have run into a problem that has had me stuck for days. I am aware there are already posts about this topic however I've read them and tried it out and I've had no luck. The problem I am having is…
Tooble
  • 81
  • 7
6
votes
3 answers

javascript minesweeper expand messing up counter

I made a minesweeper game in javascript, which was finally running pretty smoothly, until i added the "expand()" function (see below). I have 3 issues: When it expands it adds too many to "flippedCount" ( see code below ) - in the image below the…
Math chiller
  • 4,123
  • 6
  • 28
  • 44
5
votes
3 answers

Kivy Python Right Click

I'm making a game of Minesweeper with Kivy using Button widgets. I want to be able to have different actions depending on whether the mouse click is a left mouse click or a right mouse click. Can anybody help me? Below is my Cell class and the…
5
votes
2 answers

Algorithmic solution to Minesweeper

I am trying to make the minesweeper solver. As you know there are 2 ways to determine which fields in minefield are safe to open, or to determine which fields are mined and you need to flag it. First way to determine is trivial and we have something…
user216799
  • 111
  • 1
  • 8
5
votes
1 answer

Getting element of enum in array

I need to figure out how to get an element on an enum in an array. Basically, I have a grid of 9x9 buttons. I have two multi-dimensional arrays that houses these values. One houses their names (if the name is 43) it means 5 down, 4 across (because…
Anteara
  • 729
  • 3
  • 14
  • 33
5
votes
1 answer

Getting base address of a process

I'm trying to make a program that read the timer value from Minesweeper. (OS is windows 7 64bit) Using cheat engine I found the base address of the variable, but it changes every time I run Minesweeper. What do I need to do to find out the base…
yoni0505
  • 349
  • 2
  • 4
  • 8
4
votes
3 answers

Program is generating same random numbers on each run?

I just finished coding a Minesweeper type game, and everything's good except for that each time I run the application, it generates the same number (I ran it 3 different times, saved the output to 3 text files and used the diff command in Linux, it…
airplaneman19
  • 1,139
  • 6
  • 19
  • 32
1
2 3
27 28