Slashdot Log In
Using Minesweeper to Solve NP
Posted by
CmdrTaco
on Wed Nov 01, 2000 02:56 PM
from the i-want-my-np dept.
from the i-want-my-np dept.
Blue Leader writes "Boston.com is reporting that the answer to one of math's most vexing problems lies in Minesweeper. Figure it out, and render modern encryption useless." Its a discussion of NP/P, as well as an excuse to play minesweeper. Personally, I kinda prefer mahjongg or tetris tho ;)
This discussion has been archived.
No new comments can be posted.
Minesweeper: Stronger Than Encryption?
|
Log In/Create an Account
| Top
| 217 comments
(Spill at 50!) | Index Only
| Search Discussion
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Re:It is possible... (Score:3)
Consider: Minesweeper (at least the Windows version) seems to give you the first "click" free. In all my playing, I've never hit a bomb on the first click. Presumably the bomb locations are randomly located after this first click.
Now, sometimes on that first click, you get a "2" or "3", with no other spaces uncovered. What then? It comes down to luck, basically. You have no way of knowing for sure which of the 8 squares surrounding your numbers has mines, so you just have to click one and hope. Alternatively, you could click on a totally different area of the board. The odds of you not hitting a bomb are probably better if you do this, but in my experience you end up hitting a bomb enough times to make "winning almost every time" impossible.
Even throughout a game, you usually cannot avoid coming to these "decision points", where you are unable to logically deduce the locations of bombs, and are forced to make a blind pick.
Solving Minesweeper does NOT break RSA (Score:5)
All that Kaye has done is show that Minesweeper is NP complete. He has not yet found a polynomial-time solution to it, which is necessary to prove that P=NP -- in a nutshell, he just shows that Minesweeper falls into an equivalence class that holds a hell of a lot of other algorithms.
And EVEN IF HE FINDS the polynomial solution to Minesweeper, that STILL doesn't say anything about RSA (or any other "hard" algorithm), other than that it can be solved in polynomial time SOMEHOW.
The only reason people focus on this conjecture is they hope that proving P=NP and solving some algorithm will give them some magic insight into speeding up some other algorithm that's equivalently hard, rather than working on the algorithm directly. Or, disproving P=NP once and for all, and ensuring the computational assumptions that make people pick algorithms like RSA.
I always thought that minesweeper... (Score:5)
Comparisons:
Minesweeper:
- often explodes on the first click
- randomly explodes later on
- game is over quite quickly
- you have to press the reset button to restart
Windows:
- often explodes on the first click
- randomly explodes later on
- game is over quite quickly
- you have to press the reset button to restart
Its the same program!
Therefore- the Stability of Windows is NP complete! QED!
Re:Now Minesweeper is a legitimate network tool! (Score:4)
The author's webpage: (Score:5)
He also has a page specifically about this Minesweeper business here [bham.ac.uk].
I like the other paper proving that minesweeper, with a little variation, on an infinite board, is Turing-complete. Fun!
---
full of holes, it's full of holes (Score:5)
Re:Not really - let me explain (Score:3)
What do you mean, you can't prove it? Either P=NP, or P!=NP. If you discover a polynomial-time algorithm to solve a problem which is NP-complete, and you can PROVE it always works and never takes more than polynomial time, then P=NP. Furthermore, the proof that such problem is NP-complete would give you a way to solve any NP problem in polynomial time, so it would be true in practice, not only in theory. This article just says that Minesweeper is NP-complete, which is not a major result.
Mathematical details (Score:4)
More details of the maths involved can be found at The ClayMath Institute's webpage [claymath.org] and some related papers at R.W.Kaye's webpage [bham.ac.uk]
This was in the most recent Sci Am ..... (Score:3)
Math, Secondary Ed (Score:4)
I think games and optimization problems, though, could provide a fertile and interesting framework for teaching real mathematical thinking. Minesweeper. Knight's Tours. John Conway's games. Nim. Dominoes. Any small, discrete system with definable rules can get you thinking mathematically, though most people probably just play with heuristics....
NP is very bad for crypto (Score:3)
The Cure of the ills of Democracy is more Democracy.
wrong on all accounts (Score:4)
Besides P = NP for N = 1 (:-).
Re:Yeah... but how? (Score:3)
Re:fun with minesweeper (Score:3)
The basic idea is, given the current displayed numbers and the number of remaining mines, generate all possible patterns of mines in the adjacent undisplayed squares and then figure out the probability that each undisplayed square has a mine. I am not sure I follow what I was doing, but I thought some might find it amusing.
*************
SOLUTION FOR MINESWEEPER
1. Read in minefield and translate into a code where each square is assigned a number between 0 and 10, with 0 through 8 representing the displayed number of adjacent mines, 9 representing an unknown square and 10 representing a displayed mine.
2. Iterate through each square in minefield (indexes: [x][y]). If such square has a value of 0 through 8, save value of square in nNetAdjMines and test adjacent squares for "unknowns" (indexes: [c][r]). If an unknown is detected, (i) increment nAdjUnk, (ii) increment AdjUnkTable[c][r] and (iii) add a [c][r] node to pointer in KnownTable[x][y]. If a mine is detected, decrement nNetAdjMines. If nNetAdjMines>nAdjUnk, an error has occurred. If nNetAdjMines==nAdjUnk, then all unknowns for square [x][y] are mines; in such case, add [x][y] to minelist, and, after processing the entire minefield, reveal all mines on minelist and go to step 1.
3. Count all known, non-mine elements of KnownTable (nAK). Create array of nAK pointer elements (KnownArray). For each known, non-mine element of KnownTable, set a pointer in KnownArray to such element.
4. Count all non-zero elements of AdjUnkTable (nAU). Create array of nAU integers (AdjUnkArray). For each non-zero element of AdjUnkTable, reset the pointers in the linked list of each element of KnownArray to point to the corresponding element of AdjUnkArray.
5. Place each possible binary pattern of mines/non-mines in AdjUnkArray. If more mines are used than available, junk pattern right off the bat.
6. Test each such pattern by checking whether, for each element of KnownArray, the sum of the dereferenced pointers on the linked list equals nNetAdjMine. If it does, then call FinalArray(x,y,nMines), which, for a [x][y] square, increments a counter of an element in an array (CountArray) which indicates, for a given number of mines contained in AdjUnk squares (nMines), the number of patterns in which [x][y] would contain a mine.
7. For each KnownArray element, a "Factor" (equal to the number of different patterns that could be made by placing totMines-nMines mines in the non-adjacent unknowns) is applied to each CountArray element to account for the relative numbers of occurrences of the different nMines. The Factored counts are added for each CountArray element for such KnownArray member and the totals are divided by the total number of all possible patterns.
8. The relative probabilities that each unknown is a mine is displayed and/or the least probably unknown is selected. All unknowns having a 0% chance of being a mine are selected and all unknowns having a 100% chance are flagged as mines.
The real meaning of the acronym M.C.S.E. (Score:3)
Re:Do I get a million dollars? (Score:4)
X = MINE
O = COVERED EMPTY
NUMBER = BOARD CLUE
1 X
X X
The correct analysis of this board would be 'inconsistent'.
2 X
X O
The correct analysis of this board would be consistent.
The minesweeper consistency problem is a matter of checking the board and being able to declare whether or not the board is correct in all of its details.
The challenge is to construct a program which will process all generalized minesweeper boards and declare them correct/incorrect (accurately) in P. IF you can write such a program, then NP=P.
RSA is not NP-Complete (Score:5)
Any NP-Complete problem can be transformed into any other NP-Complete problem via a polynomial time transformation. Thus, solving one solves all. I have no idea how to do it, it's over my head. But it can be done.
Anyway, more to the point, this isn't about Minesweeper, it's a problem called the "MineSweeper Consistentcy Problem" and it's important to remember that. Essentially, the MCP is: given a half finished minesweeper board, is it consistent? That is, is it a valid board within the rules of the game? It is possible to get this board through normal play?
That's a bit of a different beast than just playing the game, guys.
---
Do I get a million dollars? (Score:3)
Consider a game board of any size, but in the upper-left hand corner, there sit four boxes:
[][]
[][]
If row 1, column 2; row 2 column 1; and row 2, column 2 are all mines, the four boxes look like this:
[]##
####
No data is known about row 1, column 1. Therefore, 2 possible solutions exist.
Extrapolate this, assuming similar situations on a game board consisting of billions of rows and columns, and an astronomical number of possible solutions begin to emerge.
Which, of course, is the whole problem with encryption. There are just too many possible answers (depending on key strength, etc).
In short, yes, maybe minesweeper does have something to do with encryption. However, it won't be offering solutions any time soon.
--M McCormick, Northwestern University
---sig---
fun with minesweeper (Score:4)
When I was an undergraduate, I wrote a program that would detect whether a particular move in Minesweeper was safe. It used a recursive search, and couldn't detect safe moves in certain late-game situations where the mine count was relevant, but its play was otherwise perfect.
Since the program could definitively tell whether or not a move was safe, it could detect when a player was *GUESSING*. And so we could hack the program to always reveal a mine in such cases, driving the game weenies insane. :-)
Okay, we never built the search into the game, but we did hack Tetris in a few irritating ways... (As I understand it, Tetris is a lost game anyway: with probability 1, if you play long enough, you will lose, no matter your speed or strategy.)
Important mathmatical caveat (Score:3)
It will not only NOT mean that the solution to all NP problems has been found, but it will NOT mean that a solution to any * particular* NP problem, other than minesweeper, has been found.
It will simply mean that a solution to any NP problem is * theortically findable.*
Finding the solutions to an *actual* NP problem is left as an exercise to the student, or FBI.
If NP problems do, in fact, prove to be solvable it will have an enormous impact on mainstream encryption of data transmission because such depends on having a *single,* or at least very small group, of encryption methods shared jointly by all.
Crack it once and you're into the whole system.
That be bad.
For the 'nefarious' types it won't have much impact at all, because such will be using multiple layers of multiple encryption techniques. The encrypted data will itself be hidden in non obvious places, like embeded in a minor
To sum up, if the NP problem is solvable electronic money transfers and your e-mail are inherently insecure, but terrorists, at least the smart ones, still will be.
That won't stop the FBI from playing the terrorist card to snoop YOUR e-mail though.
Now Minesweeper is a legitimate network tool! (Score:3)
And those who get caught screwing around on company time can tell their bosses, "I was just evaluating our encryption strategy."
Not really - let me explain (Score:4)
The simple truth of the problem is that there is no one answer to it...
Not many people have a firm grasp of what this problem is really all about. Sure, you'll study it in your B.Sc or B.Tech...but really, even graduates fail to grasp some key concepts, although they study the tougher concepts....basically, this is how it goes:P is the set of problems that can be solved in deterministic polynomial time. That means for a problem with inputs of size N, there must be some way to solve the problem in F(N) steps for some polynomial F. F can be any polynomial, even N to the 10 millionth power.
NP is the set of problems you can solve in non-deterministic polynomial time. That means for a problem with inputs of size N, there must be some way to solve the problem in F(N) steps for some polynomial F just as before. In NP, however, the student is allowed to make lucky guesses, though it must prove the solution is correct. The standard format for a program in NP is: Guess the answer. Verify that the answer is correct in polynomial time. For example, factoring is in NP. Suppose you have a number A that you want to break into two factors. The NP program is: Guess factors P and Q. Multiply P times Q and verify that the results is A. This takes only two non-deterministic steps so the problem is in NP. Therefore, considering the differences between the two and the estimation involved, how is it possible to prove something like this?You can't "prove this". You can't disprove it either, but that's not the point - minesweeper is not going to help you with this.
Proving P=NP does not make breaking codes easier (Score:4)
Wrong. It would do nothing of the kind. Proving Riemann's Zeta hypothesis would do that.
Even if you proved prime factorization of large numbers can be done in polynomial time, you would need an algorithm that accomplished it in a reasonable amount of time (seconds). An algorithm that had time complexity O(n^100) would still be polynomial, but useless in practice.