Some Minesweeper Configurations



Similar documents
Ian Stewart on Minesweeper

Offline 1-Minesweeper is NP-complete

Minesweeper as a Constraint Satisfaction Problem

Lecture 7: NP-Complete Problems

NP-Completeness and Cook s Theorem

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Introduction to computer science

Tetris is Hard: An Introduction to P vs NP

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Complexity Classes P and NP

Why Study NP- hardness. NP Hardness/Completeness Overview. P and NP. Scaling 9/3/13. Ron Parr CPS 570. NP hardness is not an AI topic

The Classes P and NP

6.080/6.089 GITCS Feb 12, Lecture 3

The Peruvian coin flip Cryptographic protocols

Revised Version of Chapter 23. We learned long ago how to solve linear congruences. ax c (mod m)

Polynomial Invariants

Tutorial 8. NP-Complete Problems

Boulder Dash is NP hard

Cloud Computing is NP-Complete

Microsoft Office Access 2007 Training

A Working Knowledge of Computational Complexity for an Optimizer

MAKING MATH MORE FUN BRINGS YOU FUN MATH GAME PRINTABLES FOR HOME OR SCHOOL

Chapter 1. Computation theory

Lecture 19: Introduction to NP-Completeness Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

TEACHER S GUIDE TO RUSH HOUR

Fun ways to group students

Kenken For Teachers. Tom Davis June 27, Abstract

Theoretical Computer Science (Bridging Course) Complexity

Introduction to Logic in Computer Science: Autumn 2006

Determining Degree Of Difficulty In Rogo, A TSP-based Paper Puzzle

Computational complexity theory

A Short Course in Logic Example 8

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

Tips for Solving Mathematical Problems

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

Turing Machines: An Introduction

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

CSC 180 H1F Algorithm Runtime Analysis Lecture Notes Fall 2015

Circuits and Boolean Expressions

The Basics of Building Credit

Applications to Data Smoothing and Image Processing I

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Chapter 19 Operational Amplifiers

A Short Course in Logic Zeno s Paradox

Introduction to Algorithms. Part 3: P, NP Hard Problems

Cosmological Arguments for the Existence of God S. Clarke

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Probability and Expected Value

Mathematical Induction

Björn Bäckström, Lars Olsén and Simon Renström Copyright 2011 ClaroBet AB. Updated: May. 12, 11 You may not distribute or copy any of the text or use

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Random Fibonacci-type Sequences in Online Gambling

Colored Hats and Logic Puzzles

Permutation Groups. Tom Davis April 2, 2003

An Innocent Investigation

OHJ-2306 Introduction to Theoretical Computer Science, Fall

How to Beat Online Roulette!

LESSON 7. Leads and Signals. General Concepts. General Introduction. Group Activities. Sample Deals

Website Design Checklist

The Chinese Remainder Theorem

The Assumption(s) of Normality

Boolean Algebra Part 1

[Refer Slide Time: 05:10]

CAs and Turing Machines. The Basis for Universal Computation

6.042/18.062J Mathematics for Computer Science. Expected Value I

How To Trade With Properly Scaled Static Charts

Conditionals: (Coding with Cards)

3.6. The factor theorem

Chapter 1. NP Completeness I Introduction. By Sariel Har-Peled, December 30, Version: 1.05

Universality in the theory of algorithms and computer science

Reading 13 : Finite State Automata and Regular Expressions

Bonus Maths 2: Variable Bet Sizing in the Simplest Possible Game of Poker (JB)

A Quick Algebra Review

Year 9 set 1 Mathematics notes, to accompany the 9H book.

Design a Line Maze Solving Robot

Bad Advisors: How to Identify Them; How to Avoid Them. Chapter 6. Fee-Only Advisors

FOUNDATIONS OF ALGEBRAIC GEOMETRY CLASS 22

Digital Video: A Practical Guide

each college c i C has a capacity q i - the maximum number of students it will admit

NF5-12 Flexibility with Equivalent Fractions and Pages

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 13. Random Variables: Distribution and Expectation

On the Relationship between Classes P and NP

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

What is a Domain Name?

Polynomials and Factoring. Unit Lesson Plan

STRING TELEPHONES. Education Development Center, Inc. DESIGN IT! ENGINEERING IN AFTER SCHOOL PROGRAMS. KELVIN Stock #651817

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313]

Enumerating possible Sudoku grids

The Psychic Salesperson Speakers Edition

Find-The-Number. 1 Find-The-Number With Comps

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Getting ahead online. your guide to. GOL412_GBBO brochure_aw5.indd 1 10/2/10 10:10:01

OA3-10 Patterns in Addition Tables

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

Applied Algorithm Design Lecture 5

CMPSCI611: Approximating MAX-CUT Lecture 20

PUZZLES AND GAMES THE TOOTHPICK WAY

Transcription:

Some Minesweeper Configurations Richard Kaye School of Mathematics The University of Birmingham Birmingham B15 2TT RWKaye@bhamacuk http://webmatbhamacuk/rwkaye/ 31st May 2007 Contents 1 Introduction 2 2 Minesweeper is difficult 2 3 What is NP-completeness about? 3 4 Configurations proving NP-completeness 4 5 Other questions and variations 7 Note This is a revised version of a paper originally published on the web in 1999 The copyright of this paper is held by the author, Richard Kaye You may retain a copy for your own personal use, but may not redistribute or publish any part of it, on the web or anywhere else, without permission The latest version of this paper should always be available at http://webmatbhamacuk/rwkaye/minesw/mineswpdf or via the author s minesweeper web pages at http://webmatbhamacuk/rwkaye/minesw If you did not receive this paper from that site you may have received an older version of the paper Except where contributions from other people are acknowledged in the text, all work here is by the author 1

2 2 2 2 2 0 0 2 2 0 0 2 2 2 2 2 1 Introduction Figure 1: Determine the location of all mines In a paper in The Mathematical Intelligencer, 1 I proved that Minesweeper is NP-complete The purpose of this particular document is to collect together some interesting configurations I have found in the course of the research leading to the result mentioned above For background information, please see my web pages or my Intelligencer paper The Minesweeper Consistency Problem is to determine if a given configuration is consistent (ie, that there can be real positions of mines that give the position you see) See my paper for the reason that this really is the right question to be asking about a Minesweeper configuration and why a good algorithm to solve it will enable you to play the game better In the configurations here a star,, will be used to denote a mine that has been identified A blank denotes an unknown square, and a number denotes a square that has been cleared Squares outside the thick black lines should be thought of as having been cleared, all with zeros The rules are as for Minesweeper as provided with Microsoft s Windows 2 2 Minesweeper is difficult Figure 1 gives a nice minesweeper puzzle to think about If you find it easy you probably are a real minesweeper addict, and are getting to be quite good at the game Personally, I can solve it, but don t consider it to very easy There are many variations of this puzzle, such as changing the size of the playing area Please email me with other entertaining puzzles like this that you have found or know about In general, it is not easy to tell if a guess is required at a given position in the game, or if the whole position can be calculated directly In Figure fig:mineswpuz no guess is required, but many players may not spot this fact My theorem on minesweeper, that it is NP-complete demonstrates these points very nively 1 Volume 22, number 2, 2000, pp9 15 2 Windows is a trademark of Microsoft The author has no connections with Microsoft, and nothing here should be regarded as comment on any of Microsoft s products 2

2 3 2 2 2 1 5 4 2? 4 6 6 2 2 5 5 2 1 3 4 4 0 1 4 3 0 1 2 2 3 2 Figure 2: Consider the whole playing area! 3 What is NP-completeness about? My first observation when playing Minesweeper is that it seems that the whole of the playing area must be considered when one makes a move (ie, clears a square or labels a mine) For example see the configuration in Figure 2 (Real minesweeper addicts will not find this puzzle at all difficult, but it illustrates the point) The idea that the whole of the playing area must be considered is the reason why Minesweeper configurations can be difficult, and the main reason why I originally suspected that Minesweeper is NP-complete I don t know any good mathematical way of proving that to solve some kinds of minesweeper problems you must consider the whole of the configuration, but the theory of NP-completeness comes quite close No one knows if any NPcomplete problem can be solved efficiently, but most people believe none of them can NP-complete problems all take the form of general problems requiring a yes/no answer A rather nice (non-minesweeper) example of such a problem is the BIN-PACKING problem which asks, given n floppy disks each of size x and m computer files of size y 1, y 2, y 3,, y m, is it possible to copy all of the files to the floppy disks given? Obviously some times the answer will be yes, and sometimes no It depends on the numbers n, m, x and y 1,, y m What is required is an efficient computer program or algorithm that will give the answer in all cases (Here and thoughout, I mean efficient in the technical sense of running in polynomial time ) Obviously problems like this are of great practical importance, and an efficient algorithm would be very useful Unfortunately no-one has such an algorithm, and many people suspect that there isn t such an algorithm In principle, it would be possible to prove that there is no such algorithm, but again no-one has managed to do this either Just about all that we do know is that if any of the known NP-complete problems has an efficient algorithm, then they all do and conversely if one of them can be proved not to have any efficient algorithm then they all have the same status The famous P,NP question or P=NP? question is just this: to determine whether any NP-complete problem has an efficient algorithm (in which case they all would have), or if any NP-complete problem can be proved not to have an efficient algorithm (in which case none of them would have) This is one of the biggest and most important open problem in mathematics at the moment, 3

and is the subject of a $1,000,000 prize offered by the Clay institute in the USA There are hugely important reasons why one would want to know the answer to this question, whatever the answer would be Even a negative answer that P is not equal to NP would have important practical consequences In particular, many codes used on the internet are designed on the basis that a potential codebreaker would have to find an efficient algorithm for an NP-complete problem to break the code in reasonable time I showed the consistency problem for minesweeper is NP-complete This says that to present knowledge there is no algorithm for Minesweeper much better 3 than simply checking all of the 2 n or so possible ways the remaining mines can be distributed around the n uncovered squares The diagram in Figure 2 has what I call a single wire looping round on itself A simpler kind of wire is featured in Figure 3 I came across this idea of a wire when playing the game (and other people who play minesweeper must have come across similar things) It was when I started to think about wires as wires carring a logical signal that I started to ask myself whether it would be possible to construct logic gates This turned out to be the way to prove Minesweeper to be NP-complete 4 Configurations proving NP-completeness The way I proved minesweeper is NP-complete is by designing Minesweeper configurations for logic circuits, and making a Minesweeper configuration behave like a computer (Experts will recognise that this is a reduction of the known NP-complete problem SAT to Minesweeper) For the details, you ll have to go to my original paper, but I present a few configurations here as hints for those people that might like to try to figure out on their own what they do (As a bonus, there are some configurations here that don t appear in the original paper) As before, if anyone finds other interesting configurations, please send them to me, and if I like them I ll include them in future versions of this article Figure 3 gives a wire carrying either TRUE or FALSE, but to start with there is no real difference between these truth values: we must take a somewhat arbitrary decision to define which of the two possibilities is to be called true and which false The way I define the value in the wire is this First, give the wire some orientation (here, going from left to right) Now look at the squares just behind the central 1 s in the wire (Behind, meaning with respect to the direction of the wire which we just fixed once and for all) If this is a mine, the value is TRUE else it is FALSE Wires can be bent, terminated, or split as Figure 4 and Figure 5 show (Figure 4 (b) corrects a minor error in the original paper: thanks to Harry Hutchinson for pointing this out to me) Figure 6 shows a NOT-gate I ll leave you to work out how this works To change phase, you can use two NOT gates, as Figure 7 shows The next configuration, in Figure 8, doesn t appear in my paper, but describes an XOR gate Again, I leave you the fun of working out the details The final and most difficult configuration in my Intelligencer article is the AND gate, and this is reproduced in Figure 9 A full explanation of how it 3 The phrase much better has a technical meaning which I won t go in to right here 4

X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 x 1 x x 1 x x 1 x x 1 x x 1 x x 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Figure 3: A wire X 1 2 2 1 2 3 1 1 x x 2 x 2 1 2 x 2 1 2 2 1 (a) 1 x 1 1 x 1 X X 2 3 1 1 3 x x 1 x x 1 2 3 1 1 (b) Figure 4: (a) A bent wire (b) A terminated wire 1 x 1 1 x 1 X X 1 x 1 x x 1 x 2 x 1 x x 1 x 1 1 x 1 1 x 1 X X Figure 5: A three-way splitter X X 1 1 2 2 1 1 x x 1 x x 3 x 3 x x 1 x x 1 1 2 2 1 1 Figure 6: A not gate 5

X 1 1 2 1 1 X 1 1 2 3 2 1 1 x x 1 x x 3 x 5 x 3 x x 1 x x 1 1 2 3 2 1 1 1 1 2 1 1 Figure 7: A phase-changer made from two not gates U W 1 2 3 3 2 1 2 2 u u 1 u u 3 3 w w 3 w 3 w w 1 1 1 2 u w 2 1 1 2 2 1 2 3 3 2 2 2 3 2 1 1 3 u w 3 2 1 v v 1 v v v 6 x 4 x 6 2 1 2 3 x 3 x 2 V 2 3 5 3 3 2 x 2 1 1 x 1 2 3 4 2 2 2 x 1 2 x 1 2 x 2 1 2 5 x 4 x 5 1 1 2 3 2 1 1 2 2 2 2 2 1 Figure 8: An xor gate 6

U 1 2 2 1 1 u 1 2 3 2 3 2 1 2 3 2 1 1 u 1 1 2 4 s a 1 a 2 a 3 t 3 t t 3 2 1 2 2 1 1 4 3 2 3 2 1 1 2 t 2 2 u 2 2 4 s 3 1 1 0 0 0 1 2 2 1 T 2 3 u u s 2 t 1 1 2 4 5 4 4 t t 1 t t 1 t t 1 t 2 t 1 t t 1 2 3 v v r 2 t 1 1 2 v 2 2 4 r 3 1 1 0 0 0 1 2 2 1 1 2 2 1 1 4 3 2 3 2 1 1 2 t 2 1 v 1 1 2 4 r b 1 b 2 b 3 t 3 t t 3 2 1 v 1 2 3 2 3 2 1 2 3 2 1 V 1 1 1 1 2 2 1 Figure 9: An and gate works is my Intelligencer article, as is some informaion of how to put these gates together to make up more complicated boolean circuits The main difficulties in putting these gadgets together are concern firstly how to make other standard gates (such as OR, and so on) out of the ones already found, and secondly how to cross wires over one another It turns out that both these problems were well-understood, and I showed how they can be solved in principle in my article On the other hand, if one follows the method prescribed the resulting configurations can be rather large After reading my article, Stefan Schwoon sent me (on 5th October 2000) two of his own configurations that manage to reduce this size quite a lot They are: an OR gate (Figure 10); and a way of crossing wires (Figure 11) and are also reproduced here Stefan s OR gate is substatially smaller than my original AND gate and is based on a slightly different and simpler method (I had previously spotted this sort of trick, and had used it in the write-up to my infinite version of Minesweeper, but I noticed it too late to appear in the original article) 5 Other questions and variations The NP-completeness of Minesweeper answers many questions about the game, including some I have seen posted on the web For example, it is not true that if you are playing Minesweeper and are working on a symmetrical configuration then the final solution will be symmetrical Some people have mentioned to me that playing Minesweeper is really about probabilities, not certainties I agree, but the NP-completeness result shows that the question what is the probability of a mine in square X? is even harder than solving an NP-complete problem such as the travelling salesman problem! There is no reason why Minesweeper need be played on a square or rectangular grid, and you will find plenty of other Minesweeper games on other grids 7

1 u 1 1 u 1 1 2 3 2 1 1 2 3 2 1 1 1 U V R 2 u 2 2 3 r 3 2 1 v v 3 v 6 r r 1 r 2 r 1 r r 1 2 s 5 4 3 r 2 2 2 4 4 1 2 s a 1 a 2 a 3 r 3 1 2 3 2 3 2 1 2 2 1 1 2 2 1 Figure 10: An or gate V 1 u 1 U 1 2 3 2 1 1 u 1 1 2 3 2 1 1 2 2 3 2 1 1 1 V 1 1 3 5 v 5 4 u 2 2 3 r 3 2 1 v v v v 6 r r 1 r 2 r 1 r r 1 1 1 3 4 v s 2 1 1 r 1 1 1 4 v 5 3 2 1 0 1 2 2 1 1 2 5 4 s 2 r 2 1 3 v v s r r 2 r 5 2 2 3 2 2 2 1 2 2 1 1 s 1 1 2 2 1 1 s 1 U Figure 11: A wire crossing 8

(triangular, hexagonal, ) avaiable if you look on the web I suspect that they are all NP-complete for much the same sorts of reasons I even played a three-dimensional version of Minesweeper once (This was particularly fiendish!) I recently came across some work discussing one-dimensional minesweeper played on a k n board where k is fixed and n varies The question raised was for which k is k n-minesweeper intractible? The answer, unfortunately, in uninteresting: k n-minesweeper is always tractible and the consistency problem for this is in fact solvable by a finite automaton A better question would be how large (in terms of number of states) this automaton has to be as a function of k I plan to write a show note on this later I have also worked on an infinite version of Minesweeper that is mathematically as complicated as an arbitrary computer, in the same way that ordinary minesweeper is as complicated as finite logic circuits A (somewhat technical) paper on this is now available via my web page 9