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
1
vote
2 answers

How to debug an array issue in my program?

I have been trying to program minesweeper in pygame as my first ever video game. I have been trying to create an array that tells me on every pixel how many bombs is there in a radius of 3x3 by checking inside of another array that generates 10…
1
vote
1 answer

Minesweeper program exceeding time limit

I am following a course by princeton university on cousera, I wrote the following code for the following problem: Minesweeper. Minesweeper is a 1960s era video game played on an m-by-n grid of cells. The goal is to deduce which cells contain hidden…
1
vote
1 answer

Minesweeper AI labelling mines as safe spots

Background: I have been working on the Minesweeper ai project for the HarvardX CS50AI online course for a few days. The goal is to implement AI for the minesweeper game. The problem set can be accessed here:…
Scolpe
  • 81
  • 1
  • 6
1
vote
0 answers

Minesweeper countdown

//I am trying to set a timer for my minesweeper code using java, and below is my code for timer setting. It is supposed to be a 1000sec countdown, but somehow, the program will sometimes refresh and start over from 1050sec itself, which is very…
Mary Nie
  • 11
  • 1
1
vote
1 answer

Minesweeper : Problem to recover the mines adjacent to a tile

I've got this problem. My function seems to check outside the borders of my 10x10 board. It's made to return the number of mines around a Tile[row, column] but I get : minesweeper.js:152 Uncaught TypeError: Cannot read property '0' of undefined …
user15481628
1
vote
1 answer

Minesweeper SFML code issue with revealed board

I have problem with this code. This is Minesweeper game. The game is good, but when I move the cursor outside the game window, the whole board is revealed to me. How to fix it, does anyone know? Could you help me with this problem? I think the…
Strange
  • 13
  • 6
1
vote
3 answers

Backtracking recursion similiar to minesweeper game, 2d boolean array

Basically this is a homework assignment and if you answer my question, I prefer to get a lead to the answer rather than the code and the answer itself. This has to be a recursive method, which, in a given two dimensional boolean array, has to return…
Ohande
  • 55
  • 5
1
vote
1 answer

PyQt - get row and column of clicked button in grid

I am working on a minesweeper app in PyQt and ran into a problem, how to return a row and column of clicked button in a grid layout? Below is as minimal example as possible to demonstrate the problem. My code always returns the last row and column…
user430953
  • 191
  • 2
  • 19
1
vote
3 answers

how would i check all adjacent cells for my minesweeper game?

I have been trying to figure out a way to check each adjacent cell for my minesweeper game and am coming up short. I am a beginner in python and would also like to start using OOP. however before I can even get there, I need to rectify this. all the…
AsianP123
  • 41
  • 4
1
vote
1 answer

Python Minesweeper game with GUI using Tkinter How to display on buttons correctly?

I am creating a minesweeper game in python 2.7. I have run into several problems when attempting to create the GUI. I have used a library called easyGUI (found here: http://easygui.sourceforge.net/) for some of the basic setup windows, but that is…
Nick Delben
  • 95
  • 3
  • 14
1
vote
4 answers

JavaScript: 2D Array Minesweeper accessing neighbors to += 1 them

So I have an input 2D array with already placed mines in it: const input = [ [0, 0, '*'], ['*', 0, 0], [0, '*', 0] ]; What I need to do it's to output changed 2D array with added number to neighbors, but I don't know how can I elegantly…
1
vote
4 answers

Minesweeper Program, unexpected output

I was doing one problem(Minesweeper) from Steven Skiena(Programming Challenges). Where you have to output the number of mines adjacent to that square. #include using namespace std; int main() { int n,m; cin>>m>>n; char a[m][n]; for(int…
1
vote
1 answer

Grouping coordinates of zero values in a 2D numpy array into lists based on their position in the matrix

Excluding the boundary zero values, is it possible to group the coordinates (as tuples) of remaining zero values into different lists in this numpy array? [[ 0 0 0 0 0 0 0 0 0 0 0] [ 0 1 1 1 0 0 0 1 10 2 0] [ 0 2 10 2 1 0 0…
1
vote
1 answer

Neighbor count using dynamically generated table

So basically I want to let my mines be surrounded by numbers. For instance if there are two bombs near each other and I click on a table cell next to them it should give the number 2 and when there is one bomb it should give the number 1, just like…
1
vote
1 answer

Calculating number of mines surrounding a cell in 2d array JAVA

Hi so basically I'm trying to make a beginner version of minesweeper but i got a bit stuck. I'm able to get to the stage where i have a 2d array of chars while'*' means mine and ^ doesn't. The part where i'm stuck is changing the '^' with the number…