Tetris Is Hard: NP-Hard 345
bughunter writes "Analysts at MIT Laboratory for Computer Science, who have been busy translating, rotating and dropping, have demonstrated what the rest of us suspected: Tetris is hard. Technically, it's 'NP-hard,' meaning that there is no efficient way to calculate the necessary moves to "win," even if you know in advance the complete order of pieces, and are given all the time you need to make each move. At least there's one geek classic that refuses to fall to the scrutiny of mathematicians."
Re:Winning (Score:5, Informative)
Re:Winning (Score:3, Informative)
The best Tetris game that I remember playing was Super Tetris [mobygames.com]. It had a bunch of extra features compared to classic Tetris, and 10 different levels that you could complete. The best feature was the ability to save/reload the game, so in higher levels I would just reload the game every time I made a bad move, and completed the game this way.
You may be able to find it on some abandonware site, it is lots of fun.
Re:What? (Score:5, Informative)
So, to answer your assertion that these studies are getting dumber and dumber by the day, I'd counter that while it may not produce immediate practical results, I could see this analysis being used elsewhere.
Online Tetris tournaments (Score:4, Informative)
The nice part: you bet real money. If you are somewhat good you can make some cash. I really made 25$,around 37$CDN. I stopped since it was too hard to win when I was classified as "intermediate" and I was loosing all my earnings I won "newbie".
Try it at your own risk.. Very addictive. You get 5$ free when you join. Everything is VeriSign Certified.
Re:Winning (Score:5, Informative)
Re:Poll (Score:3, Informative)
Re:Because the game is hard, or... (Score:3, Informative)
Humans and NP problems
There are two things people look at when they find a new NP problem. First is reducing a currently known NP problem to the new problem. In this case, they reduced the 3 bucket problem. Second is the difficulty of approximation. Apparently Tetris also happens to be difficult to approximate. Humans happen to be _really_ good at approximation, while sucking at exact calculations. That is the whole reason we designed computers in the first place.
Note for those who don't read the article. Their proof is _not_ for a basic tetris game. They assume a prebuilt structure that you are trying to fit pieces into. This structure is designed to allow the mapping from the 3-bucket problem to Tetris. They specifically mention the starting point of an empty board as an open problem.
Duh (Score:3, Informative)
Crispin
----
Crispin Cowan, Ph.D.
Chief Scientist, WireX Communications, Inc. [wirex.com]
Immunix: [immunix.org] Security Hardened Linux Distribution
Available for purchase [wirex.com]
Re:Winning (Score:5, Informative)
The authors carefully defines that a Tetris problem is a starting board and a series of Tetrominoes. Several computational objectives are then defined, such as "can a game be played wherein k rows are collapsed?" or "can the board after the last tetrominoe have at most height k?".
So it is really a mathematical version of Tetris, but it applies to regular Tetris in that there are certainly games that simply are too hard for you.
Re:Hrm. (Score:5, Informative)
Re:Wait a second... (Score:1, Informative)
Crispin
----
Crispin Cowan, Ph.D.
Chief Scientist, WireX Communications, Inc. [wirex.com]
Immunix: [immunix.org] Security Hardened Linux Distribution
Available for purchase [wirex.com]
Not your father's tetris... (Score:5, Informative)
Re:Because the game is hard, or... (Score:5, Informative)
How is this modded up as insightful??? Object recognition has nothing to do with this being hard. Read what it says on the bottom of page 2:
Re:Online Tetris tournaments (Score:1, Informative)
Re:Wait a second... (Score:5, Informative)
That's just wrong.
If you read the article, you would see that the fact that tetrominos (that's what they call 'em) are four block combinations does not define the magnitude of the (likely, assuming P != NP) exponential relationship. In fact, they show that the problem scales in an NP fashion with the number of pieces - the number four doesn't come into it.
What the Nintendo version shows is that a simple AI (with perfect movement abilities) and so on can come close enough to optimal in a usual situation (the article presenet an extremely contrived worse case scenario) to beat a human player. This has no bearing on the NP completeness of the problem.
On another note, the authors admit that the Tetris problem is NOT NP-Complete except for arbitrarily large game fields.
Re:Duh (Score:3, Informative)
Re:Hey... (Score:3, Informative)
Re:Winning (Score:5, Informative)
(1) Eliminating all blocks on the playfield in a minumum number of moves.
(2) Maximising the possible number of tetrises obtained.
(3) Maximising the number of lines cleared.
(4) Minimizing the height of the block configuration.
Note that they prove (1) essentially by starting from a very particular arrangement of blocks on the playing field, such that the reduction to 3-Partition is "easy" to prove (I use the word "easy" in the loosest sense). They then go on to prove (2),(3), and (4) using small modifications to the basic setup.
The admit that the "empty initial field" problem is an open one, but I would imagine that that problem can also be proven NP-Hard.
Re:Interesting Reduction (Score:2, Informative)
You are partly right; it is never NP-complete. It is also often solvable. However, in the general case it is not solvable - sometimes you just have to guess.
In fact, take the first move you have to make and tell me with 100% certainty that you're not clicking on a mine. You can't - the problem is not solveable.
Re:Winning (Score:2, Informative)
Re:Winning (Score:2, Informative)
Actually, Tetris is impossible (Score:4, Informative)
http://www.math.uic.edu/~burgiel/Tetris/explanatio n.html [uic.edu]
Has a great article about this. Essentially, in a truly random Tetris game, getting a long sequence of alternating Z and S pieces will make it impossible to complete the board; they're thicker in the middle than the sides, meaning you'll build up a little tower in the middle, no matter how good you are.
The page has links to a version of Tetris with only those pieces, if you want to try your luck on it.
P vs. NP and why should I care? (Score:5, Informative)
Perhaps you are wondering what an NP-complete problem is or what this P vs. NP stuff is all about. You might want to check out the comp.theory FAQ [cs.unb.ca] and scroll down to 7. P vs NP. It gives a bit of history and a decent description.
Or check out The P versus NP Problem [claymath.org] at Clay [claymath.org] for a really good description (unfortunately too long to quote here). And lastly, you might want to check out Tutorial: Does P = NP? [vb-helper.com] at VB Helper for a little more info.
Ok, but what is it good for? The Compendium of NP Optimization Problems [nada.kth.se] is a great place to look for real world examples of NP problems. Including everything from flower shop scheduling [nada.kth.se] [nada.kth.se] to multiprocessor scheduling [nada.kth.se].
Hopefully that helps. I was very clueless when it came to P vs. NP stuff that always seems to be mentioned on Slashdot. So I took the time to look it up. Now I'm clueless but I have links to share. :)
Re:Not your father's tetris... (Score:3, Informative)
x^n doesnt look like much when n is 'small'.
Re:This is not about tetris as you know it (Score:2, Informative)
> the case of a constant-size gameboard in time
> polynomial in the number of pieces
Here is one relatively simple dynamic programming solution.
Suppose the game board has size k. Each cell in the game board can be either on or off, so we can represent the state of the board in a bit vector with k bits. Now define a recursive procedure that takes a sequence of n blocks and a state of the game board as input: This will calculate the optimal solution, but unfortunately the program runs in exponential time. To fix that, observer that solve will only be called with 2^k * n different sets of parameters. This means that since the function only does constant work when we disregard the recursive calls, caching the results of calls to the procedure in a table of size 2^k * n, we can make it run in time O(n).
Note however that the O here is hiding a constant of size 2^k, where k is the size of the game board. This means that this algorithm, while nominally O(n), is not practical when the gameboard gets even moderately big.
What this proof is really about (Score:3, Informative)
They have shown, by reducing one NP-Complete problem to Tetris with full-lookahead, that optimal Tetris with full-lookahead is NP-hard.
Now, the reducing works by taking any instance (i.e. input) of the original problem and converting it into an instance of the tetris problem, not the other way around. So the conversion won't produce all possible Tetris games, in fact only a very restricted class of them.
This ignores two important aspects of Tetris playing:
The game is not bound by the number of pieces (so suboptimal behaviour is not really a problem)
The game is played with *random* input sets
But, as always, it's very easy to discuss something that you have no idea what it means. And, btw, being NP-complete or NP-hard doesn't mean necessarily exponential complexity (neither P=NP nor PNP have been shown).
The Raven