Tuesday, January 13, 2009

Why Do I Waste My Time Like This?

A week ago, my best "friend" Brian suggested I install Tetris Friends to my Facebook (I refer to it as FB Tetris). Why did I let him talk me into such a cataclysmic waste of time?

I've concentrated on the Sprint variant. FB Tetris Sprint requires the player to optimize clearing 40 lines with respect to time. In other words, clear 40 lines fast.

To get better at Tetris Sprint, it is a matter of math, really:

1 line = 10 blocks
1 piece = 4 blocks
1 game = 40 lines

40 lines = 40 * 10 blocks = 400 blocks
400 blocks / 4 blocks / piece = 100 pieces

To finish this game, you need at least 100 pieces to fall. That represents a perfect, waste-free game, which never happens. There are no line "bonuses" that get you to 40 lines any faster than 100 pieces. Since we are optimizing for time and there is always going to be waste, the questions is:

How much time does each block cost?

My computer isn't sufficiently precise or powerful enough to record the games and replay them, frame by frame, to see the latency cost incurred while doing certain tetris game actions such as:
  • dropping a piece straight down ("Hard Drop")
  • swapping a piece in/out of the single-piece buffer
  • clearing a line/lines (it should be noted that the time it takes to clear 4 lines is the same amount of time it takes to clear 1 line)
  • moving a piece right/left
  • latency between pressing "Hard Drop" and getting the next piece in play
The only other actions involved with tetris are:
  • thinking
  • reacting to misplaced pieces
Additionally, I haven't recorded myself playing to measure the latency of my eyes skipping around the screen.
  • your eyes will move back and forth between the piece and the playing area
  • your eyes will move around between the 2nd, 3rd, etc pieces and the playing area
  • your eyes will move right and left as you consider where to drop the piece.
I do not consider using the "Soft Drop" reasonable. You are wasting my time and yours if you think you can compete using that button.

Turns out that of all the time-consuming things above, time lost to thinking dominates all the others. In trying to optimize for time, you want to improve the areas that promise the greatest rewards first. It also turns out that latency related to eye movement is usually associated with thinking.

My FB Tetris Fundamental Assertion (FTFA): If you want to compete in FB Tetris Sprint, stop thinking.

Each of these thinking activities turns out to be counter-productive (for most players):
  • Planning to clear multiple lines at a time. Don't do it. If you lose 1/2 second to game planning, you have already wasted more time than the game takes up clearing 3 singles. Defeated.
  • Planning multiple pieces ahead. Don't fall victim to this. Eye movement back and forth and the pause needed to mentally place them erase the rewards for multiple lines.
  • Moving your eyes up to see the next piece. Your eyes must stay put. Memorize the colors and use your periphery. If your eyes are moving, your fingers are not. Generally, you'll put your eyes where you want the piece to go and use the "Hard Drop" once the shadow is there, correctly oriented.
  • Changing your mind. Go with your gut and never look back. When you've identified the next piece to come into play and identified it's resting place, never alter that plan. Moving pieces costs finger movement and time to move across board "space."
  • Using the one-piece buffer. This is about the worst thing most people can do. If it isn't enough that you've moved your eyes around to identify the piece in play and moved them back and forth across the board to locate a place for it only to determine not to use it, you then move your eyes up to the buffer piece and repeat the same series of actions. The one piece ends up costing you between 3-5 pieces, or 12-20 blocks. At the end of the day, that one buffer piece cost you two lines. If you are using the suggestion below to lay pieces flat, the worst that will happen is you have a hole which will open up in 3-5 pieces anyway. No time/lines lost.
  • Caring about where a piece lands. Sure, you meant for it to be somewhere else. It isn't. Don't ever think about it again, just play the next piece.
On the other hand, try to do the following:
  • Lay pieces flat. Laying them flat means a smaller likelihood of blocks being left behind vertically at the end. It also means less likelihood of multi-line clears, which reduces the need to think.
  • Use peripheral vision. Discussed above, this shaves worlds of time off.
  • Minimize movement and rotation. After you get good at memorizing the next piece coming into play, you'll recognize its initial orientation. In this implementation of Tetris, it is always starts out the same (which is merciful). You've identified the piece, your eyes see it's location, you know the destination location and orientation, so your fingers can get right to work, all the way to the Hard Drop before the shadow gets there. You should never rotate a piece more than two (2) times, and worse case you shouldn't move it right/left more than 5 key presses.
  • Press right/left at the same time you press rotate. Instead of losing the amount of time it takes to press 5 keys, you lose the amount of time it takes to press 3.
  • Intentionally rotate the proper/intended direction. Teach both fingers to rotate. Don't just always rotate clockwise. You'll rotate much less, and find that you don't get lost with the expected vs. real orientation only to rotate a time or two more, which also consumes tons of time. You have to wait for the game to catch up with you. For advanced Tetris players, your mind is already trained to do this. Think like Neo. "Know you're faster."
  • Keep your eyes glued to the middle of the board. Especially as you lay things flat, it will be easy and obvious where pieces should go, so your eyes will need to move less. This shaves tons of time.
In the worst game (academically speaking of course) your keypresses would be:

(5 (r/l) + 2 (rotation)) * 100 = 700

Although that is severly overstated because of (at least) the following:
  • That assumes every piece is a straight piece moved against the wall
  • You can press r/l and rotation buttons simultaneously
  • That assumes a perfect, wasteless game
So even a very exaggerated count would be:

5 (r/l/rot) * 100 = 500

Assuming that only one in four pieces will need to be moved to either edge as a worst case scenario and that the others can be positioned with at most 3 r/l movements:

25 * 5 (r/l/rot) + 75 * 3 (r/l/rot) = 75 + 225 = 300 key presses

Again, the 2 rotation key presses are done concurrently with the r/l movement key presses, so there is no need to count them explicitly. Even if you consider the possibility of having a relatively clean board, with say 10 wasted pieces (which is a ton), you just 10 * 3 = 30 more serialized key presses.

All this leads to the following:

330 key presses is sufficient to finish any game of FB Tetris Sprint.

In case you've missed how profound a realization that is, read it again. To win a game of FB tetris, you can count a very finite and relatively small number of actions you will be required to make. This means you can start eating the clock.

We could get a better approximation by using statistical methods, but I'm not good enough to do so, and the time won back won't be precise enough to make a difference. 330 is a very good approximation for the purposes of online, Flash-based Tetris.

Go ahead and try it. Press a key (or several different keys) 330 times in a row. This is your ideal game time - your time to beat. In reality, that isn't the case because NOW the other factors you have less control over come into play:
  • latency between next in-play piece
  • latency to clear line/lines
  • latency to move piece right/left after pressing the button
  • latency to rotate a peice after pressing a button
  • latency for a Hard Drop to fall
Although #1, #3 and #4 can be ignored because everybody has to do it, so it isn't time "lost" but rather time "required."

So assuming you have mastered all the above skills, the only things left are:
  • latency to clear line/lines
  • latency for a Hard Drop to fall
If you are at this point and you are optimizing even more, the way to resolve #1 above is to clear 10 perfect Tetris. es. (How do you pluralize Tetris?) That represents the time "required" to play the game. This requires being able to see not just the piece in play, but all 4 subsequent pieces in your periphery and mentally rotate/place them before you get them in play.

The only way to resolve the second one that I can think of is to make the board shorter. You would do that by sparsely dropping the first number of pieces such that you build a "platform" 1/3 to 2/3 the way up the board, and simply clear the 40 lines on a higher baseline plane. Shorter distance to fall, quicker piece turnaround time.

This, however, will likely violate the FTFA noted above (stop thinking). I suspect the time it would take to appropriately configure the pieces into a platform alone would eliminate the amount of time you gain back from drop-time latencies. Assuming it doesn't, you would likely lose time due to more strategic piece placement (to avoid death being closer to the top).

Having thought about all of this, I don't have a theoretical "best" game time, but I don't know that it matters. I also don't have a feel for how different computers may affect game time (better processor speeds, faster RAM, more RAM, springs in the keyboards, etc). At the end of the day, we aren't good enough to blame our game time on the responsiveness of the keys or handling times of the interrupts.

So, bringing it back to the original question, each block costs some sort of combination of turnaround time, rotation/relocation time, Hard Drop time and line clearing time - none of which are really measurable. However, the statistics the game provides helps us out quite a bit with the "Tetrominoes Per Minute" ("TPM") metric.

Think about it. My best time isn't that great: 1:38.45 or 1.64 minutes (98.45 seconds). My TPM? 67.03 (1.12 per second). That particular game, I played a total of 110 pieces, which represents an average amount of waste. This means that if you want your times to be fast, you just have to play more pieces per minute. I'll assume 110 pieces in a game. Consider your net time if you get your TPM very, very high:

69.4 TPM = 1:35
73.3 TPM = 1:30
77.6 TPM = 1:25
82.5 TMP = 1:20
88 TPM = 1:15

Of course, you'll likely have more waste at the end, but you didn't die which means that you're clearing lines. Tons faster. An interesting side note is that if you are wasting, you're slowly getting your baseline "platform" higher, which shaves little bits of time off the Hard Drop latency. The extra waste incurred isn't a substantial cost of time.

The net result? Keep your eyes down and count to 100. For each piece that falls, count. Play dirty. Play sloppy. Play quickly. If you concentrate on counting more than you concentrate on playing traditional "clean" Tetris, your times will drop. Quite a bit.

And maybe I'll see some competition. Say what you will about why I waste my time like this, but you just read it all, so poo on your face. Who's the bigger time waster?

14 comments:

Ashley said...

What a nice surprise to see a post from you, friend. I can't say that I read every word of it, as math turns me off and I have a huge list of things I need to be doing right now...but I am glad to see a post. Glad you're enjoying FB Tetris.

Michelle said...

Seriously, if you would have posted a graph, I may have understood what the crap you were explaining. All I know is, I see tetris pieces in my sleep.....

jjstringham said...

I can't believe you posted this. I am SO gonna kick your butt now.

Mr. Wendel said...

No, you won't.

Chris said...

Dub,
I don't have facebook, so have never played this game. Sorry. Your logic is sound, and I agree with your assertions. However, I may have found a flaw in your calculations. Doesn't a "Hard Drop" cost a keystroke? That is not included in your calculations. You account for left/right movement and rotations. If you include the hard drop keystrokes, your minimum gets bumped to 440 keystrokes (using your 10% waste assumption). I calculate that to mean that in order to get to your 1:15 time, you will need to get to 5.87 keystokes a second. That corresponds to 70 words per minute typing (assuming 4-leeter words with one space between words, and not eliminating the latency time for moving fingers from key to key). So, your ideal time (should be part of 90 day goals) corresponds to some very fast reflexes and great mental acuity.
Go for it!

Mr. Wendel said...

Chris,

I appreciate your insight. I didn't count the "Hard Drop" because it is part of the cost of the game and I count that as part of piece turnaround time, though I never explicitly said so. Thanks for clarifying that. Every player of every game has to press the Hard Drop key for every piece, so in terms of relative time it is negated, but in absolute time it should be considered.

That being said, the estimates are already very generous, so I don't feel a recalculation is necessary. I recently got a 1:35 time, wherein I had 5 pieces of waste. I was able to accomplish this with a TPM of 67, rather than the 69 mentioned. 5 pieces is about 3 TPM in 1.5 minute game.

I like your typing words per minute analogy, though it doesn't completely apply. I use a total of 5 fingers:
* Left ring: rotate counter-clockwise
* Left middle: rotate clockwise
* Right index: shift right
* Right middle: Hard Drop
* Right ring: shift left
Since the whole hand isn't coordinating, you get significantly less parallelism. This reduces your best time to a function of keyboard sensitivity/reaction time. Because the keystrokes you are making are often times the same key several times in a row, slow key springs mean slow times, irrespective of reaction time.

I have actually seen this. I will press exactly the keystrokes I need to get the piece where I want it in the orientation I want, and Hard Drop it. It will be upside-down in the wrong place because either Flash isn't handling the key presses fast enough or the keyboard is masking failed key presses.

On my 1.6Ghz, 1GB RAM Dell B130 laptop, I think I am experiencing hardware limitations before I can get my time much better. For me, 1:35 represents a pretty error-free game, with the exception of the game not honoring key presses which I then later accommodate.

I am Neo.

Spencer said...

let us all bow in your presence. this is why i slept thru math class and suck at tetris

Marianne said...

very interesting.
i'll try not to think next time i play. :P

Brian Millsaps said...

I am changing your name from "Wendelicious" to "Wendridiculous". The question is not why you waste your time like this (that's your business), it's 'why do you waste mine like this?'. You just can't be trusted to install a cool app, play it s few times and let it go. Guess I need a job at Amazon (HP will lay me off if I keep playing this thing and miss my number this quarter... in which case I will hold you accountable and expect you to get me hired).

PS - Since Tetris is a fake word (like "kleenex" or "vaccuum" or "budapest"), a conjunction of the words "Tetra" (japanese for "mind-bottling") and "Tennis" (french for "time-wasting-apparatus"), non-experts disagree on the official pluralized form...

I've seen it written as "Tetri", "Tetrises", and "Tetrisy" (supposed translation from a Russian site where the word was used). See my bibliography:

http://www.bbc.co.uk/dna/h2g2/A2479764

http://www.yourdictionary.com/community/forums/viewthread/2459/#24963

Mr. Wendel said...

Brian,
Say what you will as cleverly as you'd like, but I did notice your time drop 30 seconds overnight.

Q.E.D.

jjstringham said...

Ok. Apparently I can't help but think as I play. Because I am NOT getting better. You apparently must not think at all when you play because you are obviously the Tetris champion.

M said...

okay i happened to notice while on brit's blog that you had a new posting listed by your name. initially i was really excited! hmmm, now i think my head hurts....and i didn't even read all of it :) love ya bro

imbritney said...

I would have to say that I should have just wasted my time playing tetris rather than reading this post. No offense, just not really interesting. (and I AM a math person... just not a SW algorithm person...)

Sorry, dude!

Allen said...

I think that most people would prefer the sound of the word "Tetrises" then Tetri or Tetra. Strangely enough, my Tetris playing style doesn't comply with most of your do's and don'ts. I use only Tetrises when I play Sprint as well, and leave one entire block of space in the corner for the Tetris. Planning multiple pieces is what I always do, and I look at the Next Queue with the corner of my eye, simultaneously dropping pieces with my fingers.

Now, the type of keyboard and your computer heavily influences how well you will do in a Tetris game. For example, when I have another tab opened, I can barely paly with 20 TPM, which is quite pitiful. It's a bit hard to describe how I play better with certain keyboards, but I will try. According to Wikipedia (don't scorn me for using it), the keyboards on laptops have shorter traveling distance, which affects how much time it takes for you to press the buttons.

However, I do have to say that you have made many very good observations. These include: not changing your mind about a piece, caring about where a piece lands, laying pieces flat, peripheral vision, minimizing movement and rotation, bonuses don't do anything, and rotating both directions. Your blog has very good grammar and spelling as well, which is hard to find in the World Wide Web.

Also, when I play Tetris Sprint, I complete it in around 1:20 at a speed of about 80 TPM, which complies with your estimates.