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
-2
votes
1 answer

how can i arrange array like this

I have array like below: $matrix = array(1, 2, 1,1, 2, 1,1, 1, 1); how can I get array like below? //OUTPUT: minesweeper(matrix) = [[1, 2, 1], [2, 1, 1], [1, 1, 1]]
epool
  • 1
  • 1
-2
votes
1 answer

Recursion Issues with Arrays

I am making a MineSweeper game and am having trouble with the "clearing of all the blank tiles" when you click a blank tile. So far this is my method for clearing tiles. public void clearTiles(int row, int col) { int newRow, newCol; //up =…
-2
votes
1 answer

What is the best way to build a Minesweeper Board in a JFrame?

I am just trying to construct a gameboard with tiles to work with. I got it to work by painting the tile into rows and columns with BufferedImage, but I am going to need to constantly update the GUI as the game is played. So I tried to add the tile…
Austen
  • 15
  • 4
-2
votes
4 answers

Java equals does not work in the way I'd expect it to work

In my While loop after the first loop it does break out of the While loop but it does not step into my If check, does anyone see what I've done wrong? while (!"Y".equals(inputString) && !"N".equals(inputString)) { inputString =…
Strah Behry
  • 551
  • 2
  • 8
  • 25
-2
votes
1 answer

User determined array dimensions

I need to write a program Minesweeper.java that takes 3 command-line arguments M, N, and p and produces an M-by-N boolean array where each entry is occupied with probability p. Where I'm stuck is how to create a two dimensional array where the user…
-2
votes
2 answers

Creating a Minesweepers game in smalltalk

I'm new in smalltalk language and my teacher asked me to make a minesweeper game to exhibit later at my college class, so I need any kind of help here. All material that I found is from before 2011 and does not match with squeak 5.0(current…
Pedro Soares
  • 303
  • 2
  • 8
-2
votes
1 answer

Issue with recursion in Assembly: Coding Minesweeper

So right now I am attempting to code minesweeper for a class. The part that I am stuck on is attempting to update all the grid after a user clicks on a blank tile. Unfortunately whenever I try to run my code it just crashes. Can anyone…
Jake Hall
  • 17
  • 4
-2
votes
2 answers

Unexpected result C++

I am creating a Minesweeper game. However, while testing the generating function, It malfunctions almost always (if not always), and I do not understand why. Here is my code: #include #include #include using…
Kaiden Prince
  • 472
  • 3
  • 18
-2
votes
1 answer

Cannot properly reset JFrame

I am a java Beginner and I'm working on a MineSweeper project now. I encountered a strange problem where I cannot reset the level properly when clicking the "New" button.(Although it could work for the first few times). I think it might have…
cx040156
  • 3
  • 1
-2
votes
1 answer

Floodfill with recursion in Java

I have problem with reursive floodfilling in my minesweeper based on Swing JTable. Here's my floodfill function: public void floodfill(MouseEvent e, int row, int column) { JTable target = (JTable)e.getSource(); if…
andrew1515
  • 87
  • 7
-2
votes
1 answer

Calling a method within the same method?

I am trying to make MineSweeper for a project and I am stuck on a certain part. the explode method below works fine but It seems that I cannot call the method within the method. Without posting all the code, I wanted to see if anyone knew if this is…
Noob4sure
  • 1
  • 5
-2
votes
1 answer

Setting text on a Jbutton once its pressed

Im a big rookie in Java ( and pretty much every language). I am trying to make a Minesweeper game for an assignment and I am still in the beta stages. I am stuck however on how to display the mines as a "0" once the button is pressed. I created the…
Seeker
  • 262
  • 1
  • 5
  • 17
-3
votes
1 answer

Minesweeper revealing cells in C

I am trying to write a minesweeper program in C. What I am trying to achieve here is when user steps on one cell, the cells near without bombs and hint numbers will be revealed. For example, if x is the cell stepped on, o is an empty but concealed…
user2975716
  • 15
  • 1
  • 9
-4
votes
1 answer

Minesweeper for CS50AI - runs and then crashes

I've tried implementing an AI minesweeper for the past few days. My code runs for a 2-3 turns and then crashes.I can't find the error but i'm guessing it must be on the add_knowledge function I'm relatively new in Python Class Objects, but in…
dgsak
  • 1
  • 1
-4
votes
1 answer

Minesweeper Nearby Mine Counting

I'm trying to create a 10x10 Minesweeper-esque board made of _'s, with 10 mines randomly placed as *'s. No actual gameplay is involved, just the making of the board. I've been able to (somewhat) successfully place the mines randomly but I can't get…
1 2 3
27
28