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

I want a counter to add each time matrix[yVal][xVal] == 5

I have the following code: do{ int health = 3; int xVal; int yVal; printf("Enter an x value from 0 to 9\n"); scanf("%d", &xVal); printf("You entered '%d'\n",xVal); printf("Enter a y value from 0 to…
1
vote
1 answer

Having trouble drawing Minesweeper game board

I am working on building a Minesweeper game using C++. Right now I am lost trying to read in an input file and use the contents to build my game board to look like this: GameBoard This is what I have so far: main.cpp #include #include…
xCyberBeex
  • 17
  • 6
1
vote
1 answer

Algorithm that can compute values of variables based on the result of specific sums of those

This might be a duplicate question, but I wasn't able to find this on stack overflow. Take some variables, which all represent a chance of something. That means that all variables have a value between zero and one (both inclusive). The values of…
Samū
  • 488
  • 3
  • 15
1
vote
1 answer

Error when converting a single str character to integer and it saves in a list

Here is the code that causes the error in coordinate init: self.estate = "x" def set_estate(self, estate): self.estate = estate self.table[coordinate_line][coordinate_column].set_estate("!") I get this error: list indices must be…
1
vote
1 answer

Changing button text with button click not working

I am programming Minesweeper. I have completed all of the logic and now I am just doing the GUI. I am using Tkinter. With so many spaces on the board, I want to automate the creating of all these buttons, which I have done this way: button_list =…
Logan Holmes
  • 89
  • 1
  • 1
  • 9
1
vote
3 answers

Insert value at random place in 2D list

I'm trying to make a minesweeper game using lists in python. I have have this code so far: import random as r import sys #dimension of board and number of bombs width = int(sys.argv[1]) height = int(sys.argv[2]) b = int(sys.argv[3]) #creates the…
Alex Ruan
  • 13
  • 4
1
vote
2 answers

VBA Minesweeper: Check border cells for mine count?

I have not found much of an answer in VBA on this, but I am making a Minesweeper 5x5 board, and am trying to have cells surrounding a mine to display how many mines are touching it. I am able to get the middle 9 to work, ie the spaces with an…
1
vote
2 answers

VBA Random Mine Generation for Minesweeper

I could not find any information on this problem in the Visual Basic language, but I am trying to generate 10 and only 10 random mines for a 5x5 Minesweeper game. My problem involves the number of mines. I often only generate 4 mines, or 10+ mines,…
1
vote
0 answers

Having trouble debugging minesweeper

I'm doing some challenges over at codefights.com and I'm having trouble figuring out why my code is acting the way it is. https://codefightssolver.wordpress.com/2016/11/09/minesweeper/ ^^^There's a link to someone else blog containing the…
Tom Buck
  • 41
  • 4
1
vote
1 answer

Python - Minesweeper using Numpy: How do I count bombs around each tile?

I was trying to make a simple minesweeper board but when I execute the following code: import random import tkinter as tk import numpy as np WIDTH = 4 HEIGHT = 4 class Board: def __init__(self, width, height): self.width = width …
HasanQ585
  • 9
  • 4
1
vote
0 answers

How to generate mines, but not uncover them in a Java Minesweeper clone

I'm making a Minesweeper clone and I am currently writing the genMines method. How would I generate the mines, so they are stored into memory, but not shown on the map? Would I need a separate variable for each new mine, or would I make a separate…
Zach Mcgregor
  • 33
  • 1
  • 7
1
vote
2 answers

Java MineSweeper not counting bomb to right

For practice, I'm following a Minesweeper tutorial but it won't count the bomb to the right when adding up the number of bombs around each square and I'm not completely sure what the issue is. I've tried relaunching, opening it in multiple…
Jek Jek
  • 17
  • 2
1
vote
1 answer

Coding Minesweeper in Excel VBA: Mines are overlapping in same cell

So I'm doing a Minesweeper game for a class and everything is going fine more or less, however I had encountered a problem. Sometimes the Mines are being places in the same cell. I.e.: If i have 10 bombs sometimes 9 bombs would be displayed. Here is…
APVP
  • 11
  • 1
1
vote
1 answer

Minesweeper assignment on python

I am currently doing an assignment towards making a minesweeper like game in python using classes. For the backbone of the assignment we are just meant to import the professors premade class and create our own main function to make the class…
ruen125
  • 35
  • 4
1
vote
2 answers

Minesweeper Counting Mines not working

So, im at the point of counting the number of nearby mines ASSUMING if the spot chosen had no mines and this is what I came up with: public static int numNearbyMines( boolean [][]mines, int row, int col) { int nearbyMines = 0; if…
Brian Kang
  • 31
  • 2