Playing Tetris forever
tetrisconcept.net
tetrisconcept.net
As pointed by Scaevolus, this isn't exploiting the PRNG per se but rather the algorithm that distribute the piece, or in the Tetris jargon "the randomizer" (also "random generator").
The subject of the randomizer is such an interesting one to study.
Very early in the history of Tetris the developers have noticed that the distribution of similar piece was detrimental to the gameplay. Not because necessarily of the famous "get enough S and Z and then you automatically die" effect (that's frankly such an improbable event that you'd better try to do be struck four consecutive time be a lightning bolt), but because it often lead to the creation of a shitty stack.
So they implemented technical measure to correct that. IIRC, Nintendo's version of Tetris for NES and Gameboy were the first to do that (it's a direct detection of repetition: if PieceGenerated == lastPieceGenerated, then reroll for another piece).
Then as time went on, more elaborate system appeared My favorite one is used in the TGM series [0] : it keeps memory of the 4 most recent pieces and denies their distribution if the next generated piece is in that history. There one remarkable thing in its design is that is still distribute the piece if the "rolling of a dice" fails more than 4 times.
By doing that, they managed to have a randomizer that is both reliable (gives enough variety in the distribution of piece so to not be screwed) and unpredictible. It is a very good thing for such a single player focused game.
[0] famous in the internet for the "TGM 3 Tetris Arika !!! Invisible Tetris" and the older "Tetris Japan Finals" videos: https://www.youtube.com/watch?v=jwC544Z37qo https://www.youtube.com/watch?v=mT4TYKJuzx0
The "7-bag" system that is assumed to be used in this article is a mandatory gameplay element for all modern official Tetris (meaning, as far as I know, you cannot release a game called “Tetris” if you don’t use it). As sp332 pointed out, this randomizer uses a metaphoric “bag” throughout which you take all the 7 pieces that it contains. Once you’ve run out of piece, you put them all back in and you repeat the procedure.
It a simpler system to understand, but it has some flaws.
The main one is that depending how you connect the "seam" of the bags, you can get some unwanted repetitions (e.g finish Bag3 with a T piece and start Bag4 with a T piece as well). This phenomena is even amplified when variant of the 7-bag algorithm is used such as in (now deceased) Tetris Online Japan, where they have a 8 bag strategy or in the New Tetris ("new" here being 1999, and being the N64), where they use a 63 bag (that was actually wanted in order to build 4x4 golden square, which is the gimmick of that version).
One criticism is that it is 100% predictable: you will get any given piece in at least 14 pieces generated. Since the officiel Tetris nowadays seems to relies on multiplayer gameplay (see also: T-Spin and its offensive bonus), having a 100% predictable randomizer could be actually a strength by adding a layer of "fairness".
Further reading: there's an awesome thread [1] in Tetrisconcept.net that talk about randomizer theory. It's a old though, and some image link are dead. Fortunately, archive.org can help us restore them. Two highlights are: A comparison of different randomizer in term of predictability [2] and reverse engineering a randomizer [3] with a graph that gives the probability of having a given piece in exactly X piece [4] or in at least X piece [5].
[1] http://www.tetrisconcept.net/forum/showthread.html?t=512
[2] http://www.tetrisconcept.net/forum/showpost.html?p=20173&...
[3] http://web.archive.org/web/20080326015200/http://www.tetrisc...
[4] http://web.archive.org/web/20080326015208/http://img249.imag...
[5] http://web.archive.org/web/20080326015209/http://img249.imag...
http://www.heise.de/video/artikel/Asteroids-Helmut-Buhler-de...
Ah this explains why things didn't seem right to me. I played hundreds of hours of Tetris as a kid and I would have noticed this statistical pattern, but since my games were pre-2001, I never saw this piece pattern to exploit.
That game is event based, not frame based, so it is possible to put down multiple pieces in one frame.
Here is the same bot on a frame based game: http://www.youtube.com/watch?v=H1y_m1W-go8
You could do this on any version, but the solution would probably be hardware- and implementation-specific; I just mention the NES version because AFAIK it's regarded as the most "authoritative" version.
It could still be possible, but you'd have one more thing to reverse engineer beside just the randomizer. The game does eventually loop back to Level 0 if you get through all the bugs in "the outlands," so I guess as long as you start your game there and are able to manipulate the RNG properly then it may be feasible. The RNG is a LFSR with 32,767 positions, and the selection method is also dependent on the previous piece dealt (starts empty) and number of pieces dealt since power-on (stored in a byte).
(EDIT: There are also ways to indefinitely prolong entry delay via pause cycling. Actually, scratch that, you could even just pause a bit at the end and wait for the proper frame, assuming the other variables are properly aligned. That almost seems a bit unfair though, heh.)
The 1988 Sega arcade version might also be good for such a project. What NES was to North America in terms of being an authoritative "classic" version, Sega Tetris was to Japan. It fills an array with 1000 pieces at the start of each game, so creating some sort of looping pattern would be very possible there.
You're still confusing Tetris and Pac-Man! :)
the official tetris rules are a thing to behold. i just wanted to throw in my 2 cents worth to keep people from thinking this is an exploit for such an amazingly refined game.
there are modes of tetris that i've played that go to level 20, which means the moment the piece is spawned it's on the floor. but because of that limited maneuverability, i don't think you'd be able to use this strategy very well.
20G gameplay (i.e. where the piece spawns on the floow)) is definitely an issue, but I think that using (or rather: abusing) the Tetris Guideline very lax rotation system and "climbing" potential[1] you may be able to reach a sufficient mobility of your piece so you can place them wherever you want.
with 20g the big difficulty is when you build yourself a wall, say a single I standing upright on the floor, a couple spaces from the left side of the playfield.
now, because this is 20g, it's impossible to fill the gap on the left without first filling the gap to the right. it's true that you can move around really for as long as you like, with only the rare exception (i'm not sure, for instance, if it's possible to spin out of a spot you t-spinned into), but the problem is that it's all too easy to limit the playable area on the board. actually, i think it's unavoidable.
You are correct that it is not optimal play. What it is is a lot more interesting than what it isn't: it's a clear demonstration that survival is trivialized with the "7-bag" random generator. Tetris games used to be enjoyable to play for survival, and that is lost in recent games.
Regarding extreme speeds, you make a good observation. This pattern cannot cope with pieces spawning on the floor. That said, I 100% believe it is possible to construct such a solution.
But the existing pattern stands as something to remind people that Tetris used to be fun without extreme speeds or awareness of scoring gimmicks.
For anyone who doesn't know: I'm not big in the Tetris scene, but I do play a lot of a famous game called TGM2P. colour_thief is pretty famous around the Tetris scene for being one of the few Western Grand Masters around.
colour_thief: I'd love to talk "offline" with you sometime, is there an email I can reach you at?
There is also a variant of Tetris called Bastet, which always gives you the most unhelpful possible piece :)
Though it is possible to get the best of Bastet: its algorithm for determining the worst possible piece works by attempting to drop every piece straight down from all possible horizontal positions, and does not take sliding maneuvers into consideration. Taking advantage of this, you can create a large overhang at the top of the well, then play by building the majority of your stack under it.
That's correct, but Tetris specifies that pieces are not chosen using a sequence of random pieces selected with equal probability. Instead, it uses "selection without replacement".
Think of it as you get one of each piece and stuff them in a bag. Pull a piece from the bag. That's the next piece. Do not put it back in (hence "without replacement"). Repeat until the bag is empty then refill the bag.