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

Minesweeper draw number of nearby mines

I need to do a Minesweeper game. I have most of the methods down, but I cannot figure out a way to draw the number of mines around a given tile. I have a method that returns the number of mines around that tile, but no such method to actually…
Drakuswolf
  • 31
  • 3
-1
votes
1 answer

Minesweeper FloodFill JavaScript

Got some problems with floodfill, i don't rly understand what is wrong with it as I tried to copy some code from someone other code, it was working for him, for me not. I have got a 9x9 double dimension array as border. First i wanted to display…
cerbin
  • 1,180
  • 15
  • 31
-1
votes
1 answer

2D vector issue in c++

this is part of a larger basic minesweeper program. In the main cpp file of this program, I am loading all of the values of a matrix into a 2d vector of type int. Basically this matrix is filled with 1's and 0's which will be used to indicate…
-1
votes
2 answers

Identify a variable in minesweeper game

I need to debug a program where all the variables have been replaced by different names. The game is the minesweesper. Can someone help me just to identify what the variable pikantny is? The code: def startGame(): board = reset() …
Ana Grou
  • 19
  • 1
  • 9
-1
votes
1 answer

Issues with modifying a list based on another list?

Hello I'm fairly new to python and I'm currently trying to construct a minesweeper game. I've made 2 lists, 1 is shown to the player (field) and 1 contains the mines (minefield). I ask the player to select coordinates and the program then checks…
Aapoman
  • 21
  • 1
-1
votes
1 answer

minesweeper ruby detector arrays indexes out of

So I am creating a minesweeper game in ruby, for fun. I have completed most of it however my detector object is having issues handling the edges of the board. The board object consists of a size int and a 3d array consisting of row..col. My detector…
-1
votes
1 answer

Making minesweeper in Python and I need help changing the tiles

I am attempting to recreate minesweeper in Python and as I attempt to run the code in IDLE My question is now that how do I make it to where when the user inputs their coordinates the location changes from the "X" to "-" which is a blank tile. Also…
AAA
  • 39
  • 2
  • 6
-1
votes
3 answers

C++ Passing 2D Arrays

I am trying to create a minesweeper game that loads the board from a flat file (no, it's not random). As per the assignment instructions, I am to pass a 2d array to a load function which will then parse the file which was passed as a command-line…
-2
votes
1 answer

My CS50AI Minesweeper code causes my PC to run out of resources

import itertools import random class Minesweeper(): """ Minesweeper game representation """ def __init__(self, height=8, width=8, mines=8): # Set initial width, height, and number of mines self.height = height …
-2
votes
3 answers

Minesweeper algorithm

I am about to design my own minesweeper in Java. And while analyzing the real windows 7 minesweeper, I came across this situation. The uncovered square(pointed by arrow), may be 1 or mayn't have any number(an empty square). But in windows 7…
Muthu Ganapathy Nathan
  • 3,199
  • 16
  • 47
  • 77
-2
votes
2 answers

Minesweeper Python coding challenge

Rules are super simple: We take as input a grid of where the mines are, and we output a grid where each cell represents the number of mines explicitly around it. This means we need to check at 8 spots for each cell: Top left, Top Middle, Top Right,…
matija
  • 311
  • 2
  • 11
-2
votes
1 answer

JavaScript Minesweeper - Opening whole mine-free area at once not working properly (flood-fill)

I am trying to build a simple minesweeper game in Javascript. It works propererly apart from the function to open the entire mine-free area when clicking on a mine-free tile. It starts checking the neighbouring tiles, but stops when the first…
Sebastian
  • 7
  • 1
  • 6
-2
votes
1 answer

How do I change the variable value in the inner class

I am making a minesweeper game. I want to reduce the number of flags in the inner class but I get this error ."local variables referenced from an inner class must be final or effectively final java".How can I solve this problem ?
Burak
  • 37
  • 4
-2
votes
1 answer

Lambda Expression Local variable text defined in an enclosing scope JavaFx

I am using JavaFX to create a minesweeper game. I have a lambda expression where (for now) when I press a button from the grid of buttons, it sets the text of the button to be the location in the 2D array. I am getting the error "Local variable text…
Saksham Goyal
  • 145
  • 1
  • 11
-2
votes
1 answer

How can I pass the characters in the string inside of the list into the list of lists

I'm trying to brute force all the possible solution of the minesweeper game for my homework but I don't know how to pass the characters in the string inside of the list to the list of lists. [['1', '0'], ['1', '0']] [[' ', ' '], [' ', '…