Can Tetris play forever?

Source: Internet
Author: User

When you play Tetris, do you ever think of such a problem: if the player is enough to B, it is never possible to play dead. In other words, suppose you are the evil game machine, you are going to kill the players in front of you, you know the state of the game at any time, and can be targeted to give some obviously inappropriate blocks, try to force the player to face the worst case. So, do you have an algorithm to ensure that the player is killed, or the player has a winning strategy anyway. Note that the Tetris game area is a rectangle with a width of 10 and a height of 20, and the player can see in advance what the next given block is. You need to take this into account when designing a strategy.

I believe many people have had this experience: Play Tetris when you start to give you a "s" type of box, so that the perfectionist feel unusually awkward; as a result, the second block is still this "s", the third block is still "s", quite a crash. So, we began to speculate that if the game console gives you an infinite "S"-shaped box, the player is not the solution. The answer is in the negative. As shown in Figure 1, starting from the 10th step, the whole situation produces a cycle; as long as the machine gives the "S" block, the player can repeat these steps repeatedly to ensure that they will never die.

However, this cycle is generated when the game space is emptied. Some people will think about it, if you are playing and watching your bad situation suddenly give you an infinite number of "S" block it. In fact, the cycle of the situation may still exist, as shown in Figure 2. After the 5th "S"-shaped block is landed, the loop is generated again.

Tetris is really impossible to play dead. In 1988, a paper by John Brzustowski pointed out that the Russian block game is not impossible without solution. It gives an algorithm to ensure that the game can kill the player, even if we ask it to show the player the shape of the next block in advance. The key to the construction is that the total number of games is limited (2 of 200), and if the player is not dead, a certain state will inevitably be repeated at some point. We call the two repetition and the game process between them a "loop", and the lines that the loop actually affects are called "actual loop zones." For example, Figure 2 is a loop in which the "actual loop area" of this loop is four rows from line 4th to line 7th.

We divided the game area with 10 width to 5 channels with a width of 2, and numbered 1 to 5 from left to right. Notice that the two loops in Figure 1 and Figure 2 have one thing in common: each "S" block eventually falls completely inside a channel. In fact, we have this conclusion for any loop that has only the "S"-shaped squares. That is, if the console has always given you "s"-shaped squares, you have used them to make a loop, and there is only one possibility: all "s"-shaped squares are not located across the channel (just like the purple squares in Figure 3, not the green squares).
To prove this, we summarize the channel number. The proposition P (x) indicates that if an "S"-shaped square (or part of it) falls to the left of channel X, it must fall entirely within a channel. P (1) is clearly established: a block cannot occupy a grid on the left side of Channel 1 because there is nothing on the left side of Channel 1. The following shows that when P (N) is true, p (n+1) is also true.

We first have to prove a lemma: At any moment in the loop, there is absolutely no way in the actual loop area of channel N to appear as "-" two parallel squares. As shown in Figure 4.1, it is assumed that the row of the asterisk block in the figure is the lowest "-" structure in the actual loop area of channel N. If this line is eliminated, and by inductive hypothesis, there is no "s" shaped block that spans the left edge of the channel, so there is only one possibility: an "s" shaped block is squeezed in from the left side (Figure 4.2). But in this way, we have produced a lower "-" contradiction. This means that the row of the asterisk block has not been eliminated. But this is also impossible, because the actual cycle area is a metabolic, old replacement process, each line will eventually be eliminated.

Next, consider Proposition P (n+1). To make the "S" square occupy the channel n lattice, only the four cases of Figure 5. However, since we have previously proved that "-" cannot exist in channel N, the asterisk block is already in existence before the "S" block is dropped. Notice that the drop of each "S" block causes the "-" structure to decrease, except for the first case-it eliminates a "-" shape, but brings a new one above it, so that the number of "-" shapes remains the same. No situation can increase the number of "-". However, the number of "-" structures for channel n should be constant as it is in a loop area. Therefore, only the first case can be accepted.

Thus, only loops with "s"-shaped squares have only one case-the "s"-shaped squares overlap within each channel, filling up and eliminating several rows and returning to their original state. Each channel in the actual loop area is a pattern: the bottom is 0 or more "", the Top One "-". Note that the rightmost channel is at the top of a "-", and the right side of the gap can never be filled with a "Z" block. In other words, in a loop area containing only "S" squares, there is bound to be a line, the rightmost of which is a "-", which guarantees that the line cannot be eliminated with only "Z" squares. As shown in Figure 6, the lines indicated by the arrows cannot be eliminated with the "Z" Square, because the asterisk position cannot be filled with "Z" squares.

Below we give the algorithm for killing people in game consoles:
1. Continue to give "s" Square and show the next block is also "s" until a loop appears;
2. Give an "S" block and display the next block as "Z";
3. Constantly give "Z"-shaped squares and show the next block also "Z" until a loop appears;
4. Give a "Z"-shaped square and display the next block as "S";
5. Jump back to 1 and repeat execution.

In that case, why would the player have no solution? By the above conclusion, after the 1th step, there is a line in the game area that cannot be eliminated with "Z". Even if you give you an "s" box, this is still not possible, because the only way to fill the asterisk space is to insert an "s" into it, but this immediately creates a space where "Z" will never fit in. Then, the player gets a lot of "Z", and eventually there will be another loop, and this loop is above the one that cannot be eliminated (the loop area cannot contain a row that cannot be removed, because, as mentioned earlier, all rows of an actual loop area will eventually be erased, so that it is possible to cycle). The leftmost channel of this loop will produce a "-" structure that cannot be eliminated by "S". As a result, the game consoles also give a lot of "S", and eventually make two kinds of rows can not be eliminated alternately appear until the game over.

There are two points worth noting. First, although we assume that the game console is subjective, but in fact, even if the box is random, if you are unlucky enough, this special block sequence may just let you meet a good one, although the probability of this strange occurrence is very low, but theoretically it is still possible, So Tetris is not a game to die, there is always a time to game over. Second, this conclusion can be directly extended to the venue for any width of the Tetris game. The above-mentioned proof is equally valid when the site is of an even width, and an infinite number of square squares can be used to kill the player directly when the spot width is odd.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.