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

Core dumped while calling a function with dynamic arrays

I have segmentation fault while calling upon the recalling function "OpenCell", It doesn't want to continue no matter what. I know it's a logical mistake I just haven't figured it out yet and I am too new to C to be able to solve this on my own. P.S…
-1
votes
1 answer

I need help to debug cells in Mine Sweeper personal project

first post here. I'm a newbie, and for my personal Javscript project I'm trying to clone the old Mine Sweeper windows game. In the generating field algorithm I declared this If statement that calculates the previous number, the following and the…
-1
votes
1 answer

Why can't I detect the number of tiles touching "B" (Java Minesweeper)?

I'm making Java Minesweeper for as a simple project, but the program can never count the correct number of bombs. Here is the function, I've written, numFunction() that finds all possible combinations of touching x and y cords and iterates over all…
Wisely
  • 51
  • 2
  • 5
-1
votes
1 answer

How do I initialize my array without my entry being null?

I am building a little Minesweeper program at the moment. I initiate the playing field with a 2D array made of cells. When I initiate this array, all entry are null. How do I initiate it correctly? public Cell[,] _playField; ... public void…
Hale Jan
  • 75
  • 7
-1
votes
1 answer

Find and count adjacent array's elements in a 2D array in javascript

so im working on a function or a solution for this problem but im still a junior. this is the provided array, [javascript] ** [ [0, 9, 0, 0], [0, 0, 9, 0], [0, 9, 0, 9], [9, 9, 0, 0], ] new [1, 9, 2, 1], [2, 3, 9, 2], [3, 9, 4,…
-1
votes
1 answer

Design patterns for minesweeper

I'm trying to create a minesweeper game with design patterns, but I have trouble implementing a creational pattern for the tiles in minesweeper. In minesweeper, there are 2 types of tiles, the number tile and mines tile. The number tile contains a…
-1
votes
1 answer

Why are my minesweeper sqaures not clicking the right button?

I've been having a little issue with my code. I am trying to make a minesweeper game. as you know, minesweeper has a reset button and a timer at the top, so I've made my list start 50 from the top, to be able to add them down the line, however, this…
AsianP123
  • 41
  • 4
-1
votes
2 answers

minesweeper, reveal empty cell and all other empty cell logic and python

I am currently creating minesweeper, and have got to the part where i have to create a function that once the player clicks on a cell that is empty, it reveals that cell and all other empty cells including the numbered cells that surround the…
Pyson
  • 57
  • 7
-1
votes
1 answer

Maximum recursion error depth causing crash?

I'm making Minesweeper with tkinter. I want to have it so that when a button with 0 mines surrounding it is clicked, all the buttons around that one are automatically clicked. However, when I run this and click on a button with 0, the program…
rnbw10
  • 1
  • 1
-1
votes
2 answers

Flood fill algorithm uncovers all area (Minesweeper)

I'm implementing flood fill algorithm for minesweeper game on C++ and all is fine, but I'am not enjoyed the result of it's work. It's uncovers all area except bombs when in right version it needs to uncover some area with numbers, that represents…
Vlad
  • 3
  • 2
-1
votes
4 answers

UVA 10189: Minesweeper

Here's the link to the problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1130 This is my code and it works perfectly; however, it gives wrong answer whenever I submit it. Does anybody…
Amr Hesham
  • 87
  • 2
  • 10
-1
votes
1 answer

Combine 2 2D arrays that both contain chars with java

I have to write a code as a task for my university and we have to recreate Minesweeper with java and it has to be runned in the command line. For the matchfield we have to make an array that looks in the end like this picture: Example how it sould…
KaNt_Or
  • 3
  • 2
-1
votes
5 answers

How to turn a 0 integer into blank in java?

I am new to Java and currently working on a small beginner project. I am supposed to build a Minesweeper Java game. However, I've been looking to change an integer "0" on the board of the game to a blank space. Maybe you guys can help me out with…
Andrew M
  • 21
  • 3
-1
votes
1 answer

How to call a function within the same function in C++

I am working on a Minesweeper for a school project. I am currently working on opening up adjacent squares if the number of mines in adjacent squares is 0. I have written a function to do so. { void Square::openAdjacent(int a, int b) { …
-1
votes
1 answer

Blank space expansion in text-based Minesweeper clone in Java

I'm making a text-based Minesweeper clone in Java when an issue came up. I'm on the part where if you click a black space, it should reveal all of the blank spaces around that blank space and all blank spaces around that blank space, etc. Code I…
Zach Mcgregor
  • 33
  • 1
  • 7