Slashdot Mirror


All the Best Games May Be NP-Hard

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?"

51 of 322 comments (clear)

  1. Oblig XKCD by Zocalo · · Score: 3, Funny

    I'd say that this is most definitely NP, for humans and AI alike.

    --
    UNIX? They're not even circumcised! Savages!
    1. Re:Oblig XKCD by Kingrames · · Score: 2, Insightful

      I don't think so. I believe that's O(0).

      --
      If you can read this, I forgot to post anonymously.
    2. Re:Oblig XKCD by bondsbw · · Score: 5, Informative

      You can play it here. I'd say it's undecidable.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    3. Re:Oblig XKCD by Zocalo · · Score: 2, Interesting

      Cool. I have a strategy that might work, but it involves getting the first piece dead centre in the bottom such that it creates a level "base", then building a platform up from that on which you can actually complete rows, albeit on a reduced height playing field. The pre-requistite is that the first piece is suitable for creating the platform which, depending on whether the screen width is an odd or even number of boxes across, is a different subset of the available pieces. If you get a "Z" or "S" piece to start though, I think it's pretty much game over, no matter what you do.

      --
      UNIX? They're not even circumcised! Savages!
    4. Re:Oblig XKCD by NoSleepDemon · · Score: 3, Insightful

      Already tried that, the game is made infinitely more difficult by the physics engine which treats each block as if they have minimal mass in an almost weightless environment, furthermore, the pieces continue to move after they are 'placed'.

    5. Re:Oblig XKCD by Crudely_Indecent · · Score: 3, Funny

      I tied the top score!

      0 (zero)

      --


      "Lame" - Galaxar
    6. Re:Oblig XKCD by Anonymous Coward · · Score: 4, Funny

      I doubled your score, Loser!

    7. Re:Oblig XKCD by PIBM · · Score: 2, Informative

      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 :)

    8. Re:Oblig XKCD by jadin · · Score: 2, Informative
  2. The fun is in the simplicity by Pojut · · Score: 5, Insightful

    Tetris, to me, is the ultimate video game. It can be played by anyone ranging from someone who doesn't even know what a video game is all the way to competitive level hardcore pros.

    No other video game in history has that kind of audience. The fact that, although variations on the original have been released, the most popular version is still the original version (which has remain mostly untouched throughout its existence) just gives more credit to its simplistic genius.

    1. Re:The fun is in the simplicity by HarrySquatter · · Score: 4, Interesting

      I would argue that Mindsweeper has a far larger audience. And, yes, there are competitive mindsweeper players and leagues.

    2. Re:The fun is in the simplicity by eldavojohn · · Score: 4, Insightful

      Tetris, to me, is the ultimate video game. It can be played by anyone ranging from someone who doesn't even know what a video game is all the way to competitive level hardcore pros.

      No other video game in history has that kind of audience..

      Wrong. The concept of a game being easy to begin playing but difficult to master dates back to Chess and even Go. As far as modern day video games are concerned there are a lot that actually fall into this category. I believe the phrase was first coined by Nolan Bushnell but I could be wrong.

      You are free to say that in your opinion of "easy to learn, difficult to master" video games, Tetris is the ultimate. But even video games like Donkey Kong or Pac Man have the same simple laws that a novice understands which gradually become more and more restrictive until the true "mastery" title is nearly impossible to attain -- kill screen, anyone?

      If you're designing a new video game, that seems to be one of the fundamental requirements so that you aren't too off-putting to new players. You can play World of Warcraft at your own pace and although the UI and input is infinitely more complex than Tetris, it exhibits this basic rule of thumb for game design -- quite successfully. That's why it enjoys a worldwide audience of 10+ million.

      Tetris is legendary and fun but modern day video games (like the popular flash puzzle games) are building past Tetris while trying to maintain the principles that made it successful. I predict you're going to be upset that I might have just compared Tetris to Bejeweled but lets face it: they're both simple insanely popular video games that have a large swath of difficulties that seem to algorithmically scale in later levels.

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

      --
      My work here is dung.
    3. Re:The fun is in the simplicity by quantumplacet · · Score: 4, Funny

      exactly, because every single windows user plays minesweeper, but not tetris which is unfortunately only available for ps2.

    4. Re:The fun is in the simplicity by mdarksbane · · Score: 5, Insightful

      There's a problem, though - both Go and Chess are generally multiplayer games. Tetris is in its purest form singular. Any sort of competitive game is much harder to get into for a novice, as it is only fun for them to be playing other novices, and you have the situation you see in general with Chess and Go - the few people who are really good, and the many who rarely play because they do not have the dedication to compete.

      Look at the many addictive "casual" games - almost all of them are single player, and the ones that are multiplayer (such as farmville, or even wow) are multiplayer mostly in the social aspect than in the competitive aspect. There's a reason the majority of WoW players are on PvE. When you are facing a controlled computer opponent, you can apply a constantly ramping difficulty level that starts at a place a novice can still have fun. When you're playing competitively, the moment you have a significant skill imbalance the fun disappears.

    5. Re:The fun is in the simplicity by jpcarter · · Score: 2, Informative

      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.

    6. Re:The fun is in the simplicity by paeanblack · · Score: 4, Insightful

      Go is simpler than checkers? Is that a joke?

      It's not a joke. I can write a program to solve Go in about a dozen lines of code, without even trying to compress it. It's about as complex as tic-tac-toe.

      Building the computer that can complete this program before the heat-death of the universe? That's merely a hardware issue.

    7. Re:The fun is in the simplicity by smallfries · · Score: 2, Informative

      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.

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    8. Re:The fun is in the simplicity by Impy+the+Impiuos+Imp · · Score: 2, Informative

      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.

      --
      (-1: Post disagrees with my already-settled worldview) is not a valid mod option.
    9. Re:The fun is in the simplicity by Lando · · Score: 3, Informative

      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.

      --
      /* TODO: Spawn child process, interest child in technology, have child write a new sig */
  3. Sokoban by am+2k · · Score: 4, Interesting

    FYI, Sokoban is NP-hard as well (according to wikipedia). I'm seeing a pattern here...

    1. Re:Sokoban by owlstead · · Score: 2, Funny

      "I'm seeing a pattern here..."

      Are you sure? Maybe determining if the pattern is correct is also NP-hard.

    2. Re:Sokoban by kvezach · · Score: 4, Informative

      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.

    3. Re:Sokoban by TempeTerra · · Score: 2, Informative

      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.

      --
      .evom ton seod gis eht
  4. Just to throw this out there by NitsujTPU · · Score: 5, Informative

    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.

    1. Re:Just to throw this out there by Anonymous Coward · · Score: 4, Funny

      I have no idea what you just said. Can you use a car analogy?

    2. Re:Just to throw this out there by bondsbw · · Score: 2, Interesting

      Even more, you have to know what problem you're trying to solve. There are two obvious possibilities:

      • What is the smallest number of moves I can make to complete a 14x14 puzzle?
      • Can I complete a given 14x14 puzzle in 25 moves?

      The first is NP-Hard. But the second may be much easier... if possible, come up with an algorithm to solve every puzzle of that nature in 25 moves. Then your answer would always be yes (a tautology), and the problem is no longer NP-Hard. It's the same as if I asked if every puzzle with at least 5 colors can be solved in 1 move. That's an obvious no (a contradiction), so that question is also not NP-Hard. (I don't know if every puzzle can be solved in 25 moves... perhaps so, but maybe not.)

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    3. Re:Just to throw this out there by Bob+Hearn · · Score: 2, Interesting

      Ah, it doesn't mean that either. :-)

      If a problem is NP-hard, it means it is at least as hard as any other problem that can be solved in polynomial time on a nondeterministic computer.

      It is an open question (P=NP) whether this is equivalent to saying that there is no deterministic polynomial-time algorithm.

    4. Re:Just to throw this out there by yariv · · Score: 2, Interesting

      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

      Sadly, you seem not to understand the term yourself. NP-Hard means that given an efficient (deterministic polynomial-time) algorithm to this problem, one can devise an efficient algorithm for any NP problem, so any problem for which solutions can be verified. It might not mean that they aren't solvable (they are solvable efficiently iff P=NP), and a problem might not be solvable and still not NP-Hard. Discrete logarithm and factorization, for example, are suspected to be neither polynomial time computable nor NP-Hard (on classical models, not quantum).

      In general, the idea that we are attracted to NP-Hard problem seems quite unlikely to me. We might be attracted to hard problems, but since humans are unable to run algorithms in their heads, why would we use the notion of computational complexity for this "hardness"? It seems more likely that generating problems in the way we do is likely to produce NP-Hard problems than to say we're interested in them as games...

    5. Re:Just to throw this out there by tepples · · Score: 2, Informative

      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.

    6. Re:Just to throw this out there by SomeJoel · · Score: 4, Interesting

      If you drive from Los Angeles to New York without using cruise control, it's hard to figure out exactly how many inches you'll drive (accounting for curves in roads on whichever route you choose), but there are ways, such as maps, to get pretty close approximations.

      --
      <Complete your profile by adding a signature!>
    7. Re:Just to throw this out there by tobiah · · Score: 2, Insightful

      We might be attracted to hard problems, but since humans are unable to run algorithms in their heads, why would we use the notion of computational complexity for this "hardness"? It seems more likely that generating problems in the way we do is likely to produce NP-Hard problems than to say we're interested in them as games...

      The appeal of these puzzles is that they're hard to solve but easy to verify the solution. If the puzzle were easy you'd get bored, and if it was difficult to verify you'd get frustrated. That's why I always look for the "Certified NP-Hard" sticker on the side of my new board game purchases.

      --
      "The ability to delude yourself may be an important survival tool" - Jane Wagner -
  5. "human creativity"? by martas · · Score: 4, Insightful

    sorry to burst your bubble, but there are many poly-time approaches to solving NP-hard/complete problems that are "good enough" for many purposes. and vice versa - many (most? all?) problems that are poly-time, humans solve using heuristics that lead to often sub-optimal solutions. so what exactly is new here?

    1. Re:"human creativity"? by HarrySquatter · · Score: 2, Insightful

      Nothing really. It's just further proof that kdawson is even more incompetent than Jon Katz.

  6. chess and go aren't np-hard, but they are also fun by darkeye · · Score: 2, Insightful

    so where is the pattern?

  7. Humans are *not* good at such games--see Sudoku by mutualrecursion · · Score: 2, Insightful

    NP-hard just means you (most likely) need an exponential search. Maybe you want to take this as evidence that human creativity is needed, but that's a stretch. Humans don't do better than computers on NP-hard problems. In fact, they almost certainly do worse, because if you cannot skip the search part, computers are tremendously faster at that. See how quickly a human solves a sudoku, vs. a computer. Even though it's NP-hard (for arbitrary dimensions).

    Of course the whole thing depends on the base of the exponent. It's true that many hard problems are hopeless for computers while humans do detect some patterns and make some progress. (E.g., searches for mathematical proofs.) But the games listed have pretty well-defined, fairly small search spaces.

    Plus, the proof for NP-hardness is for arbitrary sizes, not the usual dimensions that humans play the game at. Computers are hands down better at that.

  8. Fun == uncertainty by arielCo · · Score: 4, Interesting

    Part of "fun" is uncertainty, a sense of challenge and the subsequent realization when you succeed, when there is no threat to more basic needs. Such feelings would be lessened if solving the problem was a sure thing (or if on the other extreme it looks unlikely to solve, but that's off the topic), and that's why we pick games/levels according to our skill.

    Indeed, to me Minesweeper quickly becomes boring, since most of the clicking obeys pretty simple rules ("2-3-2 along an edge - that's clear-3mines-clear"); then at the end it often becomes undecidable and it's eeny-meeny-clicky-boom.

    --
    This post contains no rudeness or derision of any kind. All arguments are friendly. Terms and exclusions may apply.
    1. Re:Fun == uncertainty by d474 · · Score: 2, Interesting

      Part of "fun" is uncertainty, a sense of challenge and the subsequent realization when you succeed, when there is no threat to more basic needs. Such feelings would be lessened if solving the problem was a sure thing

      That's what my wife said when I asked her why she cheated on me.

      --
      Authority questions you. Return the favor.
  9. Book on the Complexity of Games and Puzzles by jefu · · Score: 2, Informative

    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.

  10. Are there examples of games that AREN'T NP-hard? by Dr.+Spork · · Score: 2, Insightful

    It seems to me that earning the title of being NP-hard is very easy for games. As someone said before, even sudoku is NP-hard, but intuition-less computers are still much faster at it than humans with all their intuition. So where is the list of the "boring" games that aren't NP-hard? If there aren't any such games, then this story is pretty trivial.

  11. Re:No. by Dunbal · · Score: 2

    The human mind is created by the brain which is governed by the laws of physics.

          Rubbish. While the underlying biochemical reactions occurring in the brain are completely dependent on physical laws, the actual connections between neurons, expression of certain genes in certain cells, and levels of neurotransmitters and receptors are governed by a myriad of factors. These factors range from past experiences, conditioning and training to diet, to current amount of sunlight, etc. The brain is receiving inputs from every possible sensory organ and responding to it - modifying it's actual structure because of it, and also responding to factors in its internal environment - chemical and electrical concentration gradients.

          This is why even identical twins raised in identical environments will respond differently to the same stimulus - if only because on is sitting on the left and the other one on the right. Physics cannot explain why I, at this instant, choose to think about a magenta capybara and why you, having never heard of this creature I just made up, actually imagined one when you read it.

          We are more than the sum of our parts.

    --
    Seven puppies were harmed during the making of this post.
  12. Re:chess and go aren't np-hard, but they are also by Bob+Hearn · · Score: 5, Informative

    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.

  13. P = NP, eh? by clone53421 · · Score: 2, Funny

    I already wrote a solver for this exact game. It just isn’t efficient.

    --
    Alexander Peter Kristopeit bought his basement from his mommy for one dollar.
  14. Re:No. by Hatta · · Score: 2, Insightful

    While the underlying biochemical reactions occurring in the brain are completely dependent on physical laws, the actual connections between neurons, expression of certain genes in certain cells, and levels of neurotransmitters and receptors are governed by a myriad of factors. These factors range from past experiences, conditioning and training to diet, to current amount of sunlight, etc.

    All of which are fundamentally governed by the laws of physics. Math.

    Physics cannot explain why I, at this instant, choose to think about a magenta capybara and why you, having never heard of this creature I just made up, actually imagined one when you read it.

    Sure it can. Chaos theory. Sensitive dependence on initial conditions. Physics can't predict exactly where the next tornado will touch down either. That doesn't mean weather is independent of the laws of physics.

    We are more than the sum of our parts.

    I agree. We are the product of our parts.

    --
    Give me Classic Slashdot or give me death!
  15. Re:I'll just have to prove P=NP then. by clone53421 · · Score: 2, Funny

    Proving that P = NP is easy... you just have to start with contradictory premises.

    --
    Alexander Peter Kristopeit bought his basement from his mommy for one dollar.
  16. Re:No. by MobyDisk · · Score: 2, Interesting

    We just come with better software for it.

    We also come with better hardware for it. For now...

  17. Re:chess and go aren't np-hard, but they are also by Bob+Hearn · · Score: 4, Interesting

    I'll mention it to my publisher, but honestly it would lose a lot without all the color figures.

    The book is based on my Ph.D. thesis, which you can download for free:

    http://www.swiss.ai.mit.edu/~bob/hearn-thesis-final.pdf

  18. nonsense by pydev · · Score: 5, Insightful

    This means that there's no way to write an efficient program to beat the game, unless P=NP.

    All these games are small finite size in practice, so asymptotic complexity results tell you nothing about how difficult it is to solve them. In addition, the idea that "P = efficient program" is utter nonsense; for large problems, even quadratic complexity is a serious problem. A realistic notion these days is that a reasonable asymptotic complexity for "efficient programs" is no worse than n log^k n for small k. Anything larger than that and it won't scale. The converse is also nonsense. Just because a particular problem is NP hard in general doesn't mean that the problem instances you encounter in practice are hard cases. Furthermore, the assumption that you need to find an optimal solution is also wrong. In fact, in any competitive game, all you really care about is beating the other guy.

    P=NP is a neat theoretical issue in computer science, but its practical significance has been completely overstated.

  19. I solved it by jimbolauski · · Score: 4, Funny

    P=N*P
    N=1

    P! = N * P
    (P-1)! = N
    (P-1)! = 1
    P = 1

    Now where in my Nobel Peace Prize.

    --
    Knowledge = Power
    P= W/t
    t=Money
    Money = Work/Knowledge so the less you know the more you make
  20. Re:No. by amplt1337 · · Score: 2, Interesting

    This is the old "is the universe deterministic" debate that's been raging for thousands of years.

    My personal suspicion is that we would need to measure the variables to a sufficient degree of precision that we would hit the realm where physics is no longer strictly deterministic, i.e. that changes at the subatomic level could potentially alter the result. That's probably an overbold claim for dice (unless I want to throw in a "for sufficiently well-constructed dice" weasel), but even so, it may be the case for neurons, for which the normal level of operation is a lot smaller; a sufficiently accurate model would need to account for a lot of movement at the molecular level...

    Either way, I think that in the absence of more data, the kind of strong determinism you're proposing is really just an article of faith.

    More to the point, you aren't responding to my claim that brains can generate minds, something computers have never been shown capable of doing. I think that the ability to create a mind, and the ability to create concepts with "aboutness" through conceptual metaphor, both present in brains but not computers, are two fundamental hurdles to be overcome before we can really say that a brain is reducible to an algorithm/computer.

    --
    Freedom isn't free; its price is the well-being of others.
  21. hands up... by drsquare · · Score: 3, Interesting

    Who has no fucking idea what any of this means, and is only further confused by the wikipedia articles written by nerds who have no communication skills.

    1. Re:hands up... by phantomfive · · Score: 2, Interesting

      To be fair, there's not really a good way to explain it, even if you have good explanation skills. It's just really hard and complicated.

      --
      Qxe4