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
0 answers

(Java) Minesweeper clone not correctly revealing squares?

so basically I've been making a minesweeper clone in Java. I had it working perfectly until I added the game win and lose parts and the big opening print. Now when I run it some of the spots that are next to zero's don't get revealed, even though…
2
votes
1 answer

Minesweeper, How can I know how many 0's are next to each other?

What i want to do is be able to "turn" every 0 that's next to each other, just like the normal minesweeper game. #include #include #include #include #include int buscamina(); using namespace std; int…
2
votes
1 answer

Clicking on the form causes 'Unable to cast object of type '' to type 'System.Windows.Forms.Button'

I am making a version of the Microsoft game 'Minesweeper'. I make the buttons and labels programmatically and add two handlers for the buttons and one handler for the labels as follows. AddHandler Newbtn.MouseDown, AddressOf…
Pete
  • 23
  • 3
2
votes
1 answer

How to accelerate a lagging Swing minesweeper board?

I recently created a little minesweeper UI using the seesaw framework which is basically a nifty clojure wrapper around swing. The related code can be found here. Basically everything works fine so far, the only problem is that the user experience…
u6f6o
  • 2,050
  • 3
  • 29
  • 54
2
votes
1 answer

Minesweeper Java Inheritance

I have 5 classes for this project, Button Minefield GUI MenuBar Game. Button is an individual mine cell. Minefield contains a 2d array of buttons, and operations that concern all of the buttons. GUI is the portion above the MineField grid,…
2
votes
0 answers

C# Maximize procees doesnt work

I'm trying to maximize "Microsoft Minesweeper" (Windows 10) proccess with this code: static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] private const int…
Yaniv
  • 63
  • 6
2
votes
1 answer

How to create a MigLayout for a simple minesweeper game?

I am working on a simple clojure minesweeper game, mainly to exercise the language a bit. The "core game engine" is ready and now I'd like to add a simple UI. I had a look into seesaw and so far it worked quite nicely. The only thing I am struggling…
u6f6o
  • 2,050
  • 3
  • 29
  • 54
2
votes
3 answers

Recursive algorithm with Minesweeper not working as expected

I am trying to understand recursion and so was trying to write a recursive function for the minesweeper game. My program has no game interface as it is just for the purpose of understanding. Here is my understanding: I have a grid of given size…
Shyna
  • 145
  • 2
  • 10
2
votes
1 answer

How to know which cell of a grid (10x10) I've touched?

I'm creating a minesweeper using Canvas and a grid 10x10 I've drawn using canvas.drawRect. The problem is, I don't know HOW to get any cell's coordinates (for example : in the position (2,3) on my grid, what are the physical coordinates ?). Maybe…
Blareach
  • 23
  • 3
2
votes
2 answers

Android: Zoom Out/In of a GridLayout

I'm making a minesweeper game. I'm placing all of the buttons I use for the game in a GridLayout. The buttons eventually push the layout to be bigger than the size of the screen, so I placed the layout in a HorizontalScrollView and a ScrollView.…
user2361174
  • 1,872
  • 4
  • 33
  • 51
2
votes
2 answers

How to interrupt mouseUp-event, if control has changed

I have just finished a Minesweeper-game in Windows-Forms, which I did for practice. Everything runs just fine, but I discovered, that if you click and hold a button, it will be unfolded, even if the mouse doesn't point to that button anymore. Do you…
christian
  • 110
  • 1
  • 2
  • 15
2
votes
4 answers

MouseUp and MouseDown always have the same object sender

I'm trying to make a minesweeper clone and i'm having trouble with the mouse events. If i press a mousebutton on a picturebox and then move the mouse to another box, the mouseup event will still have the same object sender even though it happens on…
Lito
  • 43
  • 4
2
votes
1 answer

Segmentation fault/Dev C crashing

Hey guys so Im trying to do a homework and I cant find the fatal error on my program all day long.Let me explain : Firstly,you give the number of rows,col then the cells of the array (only "." for free spaces and "*" for mines, all in one row…
user3398944
  • 33
  • 1
  • 4
2
votes
0 answers

cascading reveal for minesweeper code

I am making a Java Mine Sweeper program. So far everything is going well except for the cascading and reveal. What would be the method about checking if there are any other spaces without bombs. Can someone take a look and help me? any help would be…
2
votes
2 answers

Recursive Game issue in python

I'm creating a version of Minesweeper in python and have run into a small issue. In this piece of code: if winGame(mines): printWorld(gameMap) print 'You Win!' answer = raw_input('Would you like to play again?') if…
TaylorV
  • 23
  • 3