Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I read the Wikipedia entry about "List of NP-complete problems" and found that games like super mario, pokemon, tetris or candy crush saga are np-complete. How can I imagine np-completeness of a game? Answers don't need to be too precise. I just want to get an overview what it means that games can be np-complete.

share|cite
3  
See the reference question about NP-completeness. I think your question is too broad for the stack exchange format. – Kyle Jones yesterday
2  
In minecraft, you can create.... well a computer... running.... minecraft? – djsmiley2k 20 hours ago
1  
Building calculators using Magic: the Gathering cards. Big fun :-) – Mast 18 hours ago
    
This isn't quite an answer to the question you're asking, but is so closely related that it is important to point out: the well-known game designer (and proponent of formal methods in game design) Raph Koster has theorized that the computational complexity of games is critical to our continued enjoyment of them. He defines "fun" as essentially a response to learning to improve performance of a difficult task in a non-threatening environment, and points out that continuing to do this in a constrained system like a game relies on that system having behaviour patterns that are ... – Jules 12 hours ago
    
... difficult or impossible to completely predict quickly enough to use those predictions, therefore forcing us to learn in a less direct way (usually using heuristics). Problems with a high complexity (he often suggests NP Hard) are the most reliable way of generating such behaviour patterns, which (if he is correct) is probably why they crop up in so many well-known games. See these conference slides and this book for more. – Jules 12 hours ago

It just means that you can create levels or puzzles within these games that encode NP-Hard problems. You can take a graph coloring problem, create an associated Super Mario Bros. level, and that level is beatable if and only if the graph is 3-colorable.

If you want to see the specific way the NP-Complete problems are translated into the games, I recommend the paper "Classic Nintendo Games are (Computationally) Hard". It's well written and easy to follow.

An important caveat to keep in mind is that the NP-hardness requires generalizing the games in "obvious" ways. For example, Tetris normally has a fixed size board but the hardness proof requires the game to allow arbitrarily large boards. Another example is off-screen enemies in Super Mario Bros: the proof is for a variant of the game where off-screen enemies continue moving as if they were onscreen, instead of ceasing to exist and being reset to their starting position when Mario comes back.

share|cite|improve this answer
3  
Not worth an answer on it's own, but the following has a nice video lecture: courses.csail.mit.edu/6.890/fall14/lectures/L05.html - Crystal clear explanations. – user340082710 yesterday
3  
It may be worth including a precise statement of a theorem from the (hugely interesting!) paper that you linked, which succinctly and precisely explains exactly what it means to say that a game is NP-hard: It is NP-hard to decide whether the goal is reachable from the start of a stage in generalized Super Mario Bros – ymbirtt 21 hours ago

I honestly don't know exactly what kind of model is used by the people making those claims; however, what seems reasonable to me would be talking about the $\mathcal{NP}$-completeness of deciding something about a game situation.

Let's take as an example Tetris, since it's the only one from those you quote that I understand enough to talk about. Tetris has a rule called "perfect clear", that gives the player a large bonus if a piece drop clears the board entirely. One might wonder if, given an ordered sequence of pieces $\{P_i\}$ and an integer $k$, there exists a legal sequence of moves for the pieces $P$ that achieves at least $k$ perfect clears. Problem statements such as those are sufficiently abstract that can be modeled with the tools of complexity theory.

Long story short, "$\mathcal{NP}$-complete" means one thing and one thing only, fancy claims such as "Super Mario is $\mathcal{NP}$-complete" have to be translated into a formal statement before they make any actual sense.

share|cite|improve this answer

Here's a simplistic hand-waving explanation:

Such games are in NP because "running" a player's behavior over the course of a game and checking whether s/he wins or loses can be done efficiently (we need it to be in polynomial time in the length of the game, but it's probably linear or $O(n \log(n))$-ish).

Such games are NP-hard because the player's behavior is very expressive. While at any given point a player may only have a limited, even a fixed, number of possible actions, that's enough to create a space of behaviors or strategies exponential in the length of the game; and while you may be able to provide a simple condition or logical formula on the validity/benefit/correctness of a player's actions locally, globally you get a similar effect as with a large combinatorial circuit, or a k-CNF formula.

Hopefully this makes some intuitive sense and also rings enough CS theory bells.

share|cite|improve this answer

I'll try to rewrite my response to address some of the points raised by Cort Ammon.

I assume that you read the Wikipedia definition for NP-completeness and and didn't understand it. I'll water down the exact meaning just a bit and explain what I think is the essence of the concept.

Basically when you're playing a game you have some number of moves that you can make and you must chose one of them. You'd like to play "perfectly" which means that you'd never make a "bad" move. So of the allowable moves you'd like to select the best one.

Note that perfect play doesn't mean that you'll always win. The rules of the game can be such that the first or the second player should win. Also some games like Tic-Tac-Toe should end in a draw. Thus what "perfect play" means in this discussion is (1) that you'll never be in a winning position and then lose the game because you made a "bad" move and (2) you'll never miss an opportunity to get into the winning position if such an opportunity arises.

Given the current state of the game what you'd like is to be able to use an evaluation function to calculate the best move rather than search the whole game tree. So the evaluation function would take as input the current game state and calculate what would be the perfect move.

Notice how I am using "calculate" and "function" here. A computer does calculations of course but I don't mean calculate in that sense. By saying "an evaluation function to calculate" I mean like evaluating a mathematical formula. I am specifically trying to exclude an exhaustive tree search of future board positions.

For Nim it is possible to create such a function. The function can calculate if you have a winning move and what that move should be.

On the other hand let's take the game of Qubic. (You're trying to make a line of 4 in a 3D grid. So it is essentially tic-tac-toe on a 4x4x4 grid.) Qubic is NP-complete thus there is no function to calculate the next perfect move. The only way to know if you currently have a winning move is to try all the possible moves of both players to verify that a particular move is a winner, or at least not a loser.

Truthfully the whole game tree for Qubic is small enough so that it can be encoded into a computer program which can play perfectly. What encoding means is that the whole game tree has been explored and all the moves worked out in advance. So the program can essentially do a database call using the current board state and get back the best move for that board state without having to do the tree search each time a move is to be made.

Chess is still an unsolved game. It is unknown if the first or second player should win. It is not possible to be given any board position and predict with certainty who will win. In fact chess has such a large game tree that it is just impossible to search the whole game tree. You'd need computers which are not just 10 or 100 times faster but billions of billions of time faster than any current computer. Thus even with some move look aheads, all chess programs ultimately use an imperfect evaluation function. Think of the chess evaluation function as giving each possible next move a probability of being the best move. That means that might be possible to beat the program even if the program had a winning position at some point.

share|cite|improve this answer
4  
Can you cite your source for NP-completeness? That does not resemble any definition of NP-complete that I have seen. That's more of a definition of uncalculatable. – Cort Ammon 12 hours ago
    
@CortAmmon - Incalculable is the essence of NP-complete when choosing a move in a game. So when applied to a game it means that you have to brute force search the rest of the game tree from the current game state. // Note that I am using "incalculable" to mean there is no function to calculate the each next perfect move for the rest of the game. A computer can play a perfect game of Qubic for example because the whole game tree is small enough that it can be codified. So in that sense Qubic isn't "incalculable" for a computer. – MaxW 12 hours ago
1  
I believe you are confusing two very different concepts. NP-complete problems are indeed calculatable, just not in polynomial time by a deterministic turing machine. Your definition is close to the correct one, but NP-completeness is a specific enough topic that rigor is valued. You can get in a lot of trouble by using a less rigorous definition because it can lead you to some rather deceptive conclusions. – Cort Ammon 12 hours ago
    
@CortAmmon - I'll agree that my answer isn't rigorous enough for a research paper on game theory. But I tried to give the OP an answer that I thought he would understand. Is there some correction that would make my answer acceptable to you? – MaxW 11 hours ago
    
I'd say at the minimum use the correct definition for NP-completeness. I think Craig Gidney captured the other key part, which is that you have to generalize the games so that you can map them to the integers before we can talk about P or NP for a particular game. Qubic, Nim, and Chess are all not NP games because of their fixed size, but the generalizations of Nim are typically all P while the generalizations of Chess can be NP (such as Chess on a nxn board with 2n pieces on each side) – Cort Ammon 11 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.