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

javascript minesweeper floodfill algorithm not working as it should

I'm trying to write my first simple minesweeper game. For revealing empty fields I wrote a simple flood fill algorithm, however it isn't working as it should. Here's a snippet of code: function reveal(a,b){ var fieldId = getFieldId(a,b); /* cells…
Furman
  • 2,017
  • 3
  • 25
  • 43
1
vote
0 answers

How to update remaining mines label in GUI Minesweeper game?

I am making a minesweeper game in Java, and I have the game mechanics and visuals completed. However, I am trying to find a way to update the label displaying mines remaining during the game. When the user places a flag, the count should go down by…
Mandias09
  • 11
  • 2
1
vote
2 answers

JAVA objected 2D array ,Can't set the element in array nor call the function in it

i'm trying to create an minesweeper game using this Class Diagram I'm stuck here for 2 hours and can't find any solution to it,while i'm trying to call the function in the GridData class,the NullPointerException always heppen,Also i can't change the…
1
vote
1 answer

Board in minesweeper in C

I'm learning programming. I started from basics. Ok, I have to do minesweeper. I think it will be good, but in real I don't see the board. I don't know why. I think I wrote the function which shows the board. #include #include…
1
vote
0 answers

Black lines when scaling canvas bitmaps

I'm trying to make a Minesweeper game in android to practise using Canvas to draw images. I'm currently using drawBitmap(image,x,y,antialiasPaint) but, when I resize the board and the tiles become so small, this occurs: Image You can see the black…
Scop
  • 11
  • 1
1
vote
3 answers

javafx Minesweeper: how to tell between right and left mouse button input

I am working on a javafx Minesweeper game, and currently am only using left mouse button input. I would like to use the right mouse button also so users can flag possible bombs. I looked at the Oracle webpage for Button class, and it says: "When a…
TheTotalJim
  • 67
  • 2
  • 13
1
vote
1 answer

Javascript flood-fill function working only partially [Minesweeper]

I've been trying to create my own minesweeper-game (for fun) for a couple months now. Only thing that I have really been stopped by is how to make recursive function (flood-fill) to fill the blank areas in the game. The flood-fill works only…
user5641726
1
vote
2 answers

Minesweeper game board in

I have to create a function that creates a game board for minesweeper (I am also very new to coding). I intend to have the board initially start with every space being covered and mine free, represented by the string "C ". I then need to assign…
1
vote
1 answer

Where are the memory leaks? 2d array class

I submitted this program for a class and the error message says that there are a few memory leaks, but I cannot find them (I even asked another professor) Here is the error message: ==27796== HEAP SUMMARY: ==27796== in use at exit: 160 bytes in…
1
vote
2 answers

I am having trouble calling code from a class

So I am fairly new to java and I am working on a graphical user interface for a simple game of minesweeper. Originally I had all my code integrated into one class and instantiated my Panel and Frame in the same class, but my professor insisted I…
Dayman
  • 67
  • 1
  • 7
1
vote
1 answer

Recursive Method StackOverflow Error - Minesweeper

I am writing the recursive method for a minesweeper game and I am encountering a stackOverflow error in the recursive method that clears out empty spaces, The error does not occur when checking for 3 of the surrounding spaces but only when checking…
1
vote
1 answer

Make Cells in Python Curses

I am trying to make a Minesweeper game in python's curses and I wanted a way to distinguish every pixel but still having every pixel blank. Is there some method or function in curses that you can use that works like the border() method but instead…
Alexander Simko
  • 183
  • 2
  • 12
1
vote
1 answer

How can I check if any button of a two dimensional array was clicked?

I am trying to build a minesweeper program. So far, I made a two-dimensional array of buttons with the variable Buttons[rows][cols], so you can target every button on the field. The buttons are created on the form at runtime. Now I need to know how…
Tim Lâm
  • 124
  • 1
  • 2
  • 13
1
vote
2 answers

Minesweeper neighbor count

I'm trying to replicate Minesweeper and I encountered a problem counting neighbors that are mines. It seems like a very easy thing to implement, but for some reason I'm not getting the desired results everywhere. I have a 1d array of ints…
Stefan Dimeski
  • 438
  • 4
  • 16
1
vote
3 answers

Python/PyGame Select a Random Boolean From List

Python version: 2.7.8 Objective: Making a Minesweeper game (trying to at least) on python with the PyGame library. The Code: import pygame, random, sys from pygame.locals import * pygame.init() width, height = 400, 400 clock =…
Adam
  • 15
  • 3