Tetris NP
Tetris NP
Tetris NP
An Introduction to P vs NP
Is
"
TETRIS?
How much harder does this get as the gameboard gets bigger?
Find an algorithm A that decides if "g, s# TETRIS.
Measure resources consumed by A.
12
200
x 10
180
10
160
140
120
100
80
4
60
40
2
20
Polynomial
10
10
12
14
16
18
Exponential
20
Computable Uncomputable
Hard
Complexity Classes
A complexity class is a set of languages.
A language L (PRIMES, TETRIS, ...) is a member of the
following complexity classes if there is an algorithm A ...
P
EXPTIME
Complexity Hierarchy
EXPTIME
PSPACE
!
Efficient Space
P
!
Efficient Time
P PSPACE EXPTIME
P &= EXPTIME
So TRAVELING-SALESMAN might be in P!
But notice:
For a particular ordering of the coffeeshops, its easy to check
if the length of the trip is under one hour.
(Just add up the times.)
10
NP, continued
A language L is in NP if I can give you an argument A and
then you can check that A is right in polynomial time.
NP: Nondeterministic Polynomial Time
Nondeterminism: I give you an argument; you check it.
For some games, like CHESS, the move sequence might be
too long to check in polynomial time!
Complexity Hierarchy
EXPTIME
PSPACE
!
NP
!
P
!
Chess, Checkers
Go, Othello, Sokoban,
Generalized Geography, Hex
Tetris, Mastermind,
Minesweeper, Sliding Blocks,
Traveling Salesman
Jenga, Im Thinking of a Number
P &= EXPTIME
P NP PSPACE EXPTIME
13
P vs. NP
NP&=P
We do not know which is true!
P=NP
NP-completeness
First major step on P vs. NP problem [Cook and Levin, 1970s]:
An NP-complete problem:
!
1. is in NP
2. is as hard as the hardest problem in NP.
NP
16
16
B
f
f
xA
if and only if
f (x) B.
Were interested
in efficient f .
NP-Completeness Summary
Karp.
18
19
Our result:
There is an efficient reduction from 3-PARTITION to TETRIS.
20
initiator:
filler (a1 times):
6T + 22
terminator:
...
a2
initiator:
...
a3s
terminator:
Finally:
6s + 3
...
s,
, and
( 3T
2 + 5).
21
Reminder: NP-Completeness
22
..
23
Reminder: NP-Completeness
25
...
26
For x
/ L, we need m(x)
/ TETRIS
No means no.
Step #1: if you dont (or cant) make the moves from two
slides ago, you get into one of the following configurations.
Step #2: if you get into one of these, youre hosed.
not div. by 4
27
Reminder: NP-Completeness
28
Statement of Results
Our results actually apply for some other Tetris questions, too:
can we clear at least k rows?
can we place at least p pieces without losing?
can we place all pieces without filling a square at height h?
can we achieve at least t tetrises?
All of these are NP-complete.
29
pieces
to our sequence.
Can get into (and clear) lower
reservoir (using extra
pieces)
30
s and
[Brzustowski/Burgiel]
Implies that probability of a real Tetris game lasting infinitely
long is zero (regardless of players skill).
On the Tetris gameboard that you know and love.
(Our complexity results are as the gameboard grows.)
31
33
35
36