Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?
Games Science

All the Best Games May Be NP-Hard 322

Catullus writes "Following in the footsteps of Tetris and Minesweeper, the simple yet addictive multiplatform game Flood-It is the latest puzzle to be proven to be hardNP-hard, to be exact. This means that there's no way to write an efficient program to beat the game, unless P=NP. This research by computer scientists from Bristol University raises the intriguing question: are these games fun precisely because they're hard for computers to solve, and need a spark of human creativity?"
This discussion has been archived. No new comments can be posted.

All the Best Games May Be NP-Hard

Comments Filter:
  • by NitsujTPU ( 19263 ) on Friday April 09, 2010 @12:34PM (#31790934)

    Since I had to suffer through at least one professor who didn't understand basic complexity theory last night, and I know that Slashdot generally screws it up to.

    NP-Hard means that there's no (deterministic) polynomial-time algorithm to solve the games. Additionally, you always have to generalize these games in order to make that claim. Since computational complexity is defined in terms of the length of the input, and certainly all of these games are being played on an input of fixed length.

    However, there are effective approaches to solving NP-Hard problems. There are solvers for known NP-Hard problems. If you Google "sat solver" you'll find at least 5 that you can just download. SAT solvers are used in VLSI validation and other practical things. These solvers use heuristics to improve search performance, generally proposing answers and checking them (for NP-Complete problems).

    Also, there are tons of games known to be NP or PSPACE complete. The reductions for those games are kind of a standard problem, since the AI community writes a bunch of these solvers.

  • Re:Oblig XKCD (Score:5, Informative)

    by bondsbw ( 888959 ) on Friday April 09, 2010 @12:35PM (#31790940)
    You can play it here []. I'd say it's undecidable.
  • by Anonymous Coward on Friday April 09, 2010 @12:44PM (#31791100)

    Well to be pedantic, you aren't quite right either. NP-Hard means there is no KNOWN (deterministic) polynomial-time algorithm. If P==NP, then there will be some polynomial-time algorithm.

  • by theaveng ( 1243528 ) on Friday April 09, 2010 @12:51PM (#31791204)

    >>>Not sure if I would agree with Minesweeper having a larger audience

    How many users of Windows are there? Approaching 1 billion homes? That's a bigger audience than even the best-selling console (~150 million PS2s) ever reached.

  • by jefu ( 53450 ) on Friday April 09, 2010 @12:55PM (#31791256) Homepage Journal
    There is a fun book on this topic called "Games, Puzzles and Computation" by Hearn and Demaine that is well worth a read if you're interested in puzzles or complexity.
  • by Bob Hearn ( 61879 ) on Friday April 09, 2010 @12:59PM (#31791308) Homepage

    Chess and Go are actually EXPTIME-complete, even harder than NP-complete problems and PSPACE-complete problems.

    In general, one-player games of bounded length (like Flood-It, or Sudoku) tend to be NP-complete; one-player unbounded games (like sliding-block puzzles, or Sokoban) tend to be PSPACE-complete; two-player bounded-length games (like Hex, or Amazons) also tend to be PSPACE-complete, and two-player unbounded games (like Chess, Checkers, and Go) tend to be EXPTIME-complete.

    I can't resist here a plug for my book (with Erik Demaine), Games, Puzzles, and Computation [], which discusses all these issues in detail. A theme running throughout the book is the same as the view expressed in this paper: most interesting games and puzzles seem to be as hard as their "natural" complexity class, outlined above.

  • Re:Oblig XKCD (Score:3, Informative)

    by PIBM ( 588930 ) on Friday April 09, 2010 @01:12PM (#31791510) Homepage

    I made a nice line yet got no points. I guess they weren't thight enough or they just never plugged in the points calculation :)

  • by tepples ( 727027 ) <> on Friday April 09, 2010 @01:15PM (#31791564) Homepage Journal

    The "no polynomial-time algorithm" bit is only true if P!=NP.

    And to the best of human knowledge, it happens to be the case that P!=NP.

  • by jpcarter ( 1098791 ) on Friday April 09, 2010 @01:39PM (#31791964)

    I think my point is that Minesweeper has been sitting on nearly every desktop in the world, from Windows 3 (1990) to Windows 7 (2010). Other games have not. QED Minesweeper has far wider "coverage" to borrow a term from Nielsen television.

    But if Windows users had the choice of the two, Minesweeper or Tetris, automatically available to them, I'm confident that Tetris would win hands down.

    What was Peter playing in OfficeSpace? Not Minesweeper.

  • by roman_mir ( 125474 ) on Friday April 09, 2010 @02:26PM (#31792718) Homepage Journal

    As an avid Tetris player, I must inquire when it is that one is given the "competitive level hardcore pro" title in Tetris?


    Watch this to the end, you'll see. []

  • Re:Sokoban (Score:5, Informative)

    by kvezach ( 1199717 ) on Friday April 09, 2010 @02:57PM (#31793154)
    The minesweeper decision problem is actually: "Given these mine hints, is there any possible way mines could be set on the field so that you would get these hints when uncovering these squares?". It's a reduction from SAT. It's NP because given an answer, you can check if the mine hints would be what the problem states. It's NP-hard because SAT is. Together, NP and NP-hard makes NP-complete.

    Note that NP-hardness isn't about the average case, it's about the worst case. Many proofs of puzzles being NP-hard essentially go: "I can make a playing field so that the puzzle is only solvable if a related Boolean circuit can be satisfied, and I can transform any Boolean circuit into a playing field in this manner". Such a proof only tells you that these "gadget puzzles" (transformed circuits) are as hard as SAT, it says nothing about the average puzzle.

    As another example, consider a problem where the input is either 0, an integer, and a number of integers; or 1, and a number of integers. Then the decision problem is defined as "if the first number is 0, then true if the second is the sum of all the subsequent integers of the input; if the first number is 1, then true if the circuit defined (in some given format) by the subsequent integers can be satisfied". Obviously, this problem is NP-complete because you can turn any SAT problem into an instance of this problem; but if the first number is 0, the problem is trivially decided.

    Incidentally, that's part of the reason why cryptosystems based on NP-hard problems have done so badly: while the cryptosystem might be hard to crack, worst case, it usually turns out most instances of encryption can be broken.
  • by smallfries ( 601545 ) on Friday April 09, 2010 @02:58PM (#31793170) Homepage

    Are you saying that you couldn't write a program to solve checkers in twelve lines of code?

    Such a simple brute force solver still needs an executable specification of the rules that converts a board state and a move into a new board. For checkers this function is simple. For Go this function needs to check the freedoms of each cluster of stones and would thus require recursion. This alone would make it a more complex program than the checkers solver.

  • Re:Sokoban (Score:3, Informative)

    by TempeTerra ( 83076 ) on Friday April 09, 2010 @03:11PM (#31793316)

    Briefly (and wrongly, but it will do for a slashdot reply), NP complete problems require the computer to actually calculate all of the possible solutions and see which one is best rather than than using an algorithmic shortcut. For every extra item that has to be computed the complexity increases by quite a large amount relative to the difficulty of the smaller problem. The traveling salesman problem is the classic example - adding another town to visit means you have to recalculate all the routes because there just might be a better solution using the new town in any part of the route.

    Anyway, there's nothing impossible about NP complete problems - the issue is that they get very hard very quickly as you make the problem space bigger. Quickly the time required to find the best solution (not just a good one) would take longer than the remaining lifetime of the universe.

    One of the tricks with NP complete problems is that if you're looking for a merely good solution, not the absolute best, humans can often use some heuristic tricks to home in on a good solution quickly while a dumb computer algorithm would still be chugging away looking exhaustively for the best solution. Studying the kinds of guesses that humans make in these situations is a notable area of study in artificial intelligence.

    In summary, a computer will kick you ass at minesweeper, but it still won't be able to solve a 10^14 x 10^14 board before the end of time.

  • Re:Oblig XKCD (Score:3, Informative)

    by jadin ( 65295 ) on Friday April 09, 2010 @03:13PM (#31793330) Homepage

    First Person Tetris []

  • by Impy the Impiuos Imp ( 442658 ) on Friday April 09, 2010 @03:25PM (#31793480) Journal

    Actually, poking a random square is NP-easy, so to speak. It's just not guaranteed a solution.

    Remember that NP-Hard means essentially there is no way to solve a problem short of basically trying all possibilities. And that's exactly what a human mind is doing in Minesweeper.

  • I think your using a poor choice in words. Your saying that go has a simpler rule base than checkers, ie it's easier to determine whether a rule is valid or not, correct? Not the actual strategy and hence wining of the game.

    Considering that checkers is a solved game with 10^31 moves. Chess being 10^50 and Go an estimated 10^80 if I recall correctly.

    So figuring out a valid move may be easier in Go than in checkers; however, it's the gameplay/strategy that really counts.

A hacker does for love what others would not do for money.