Wednesday, July 3, 2013

Tetris Pieces, Exponential Growth, and Unexpected Cryptography

I talked about Tetris a few weeks ago (here), and examined the counts of pieces across a number of games. That got me thinking about Tetris pieces, especially when I started to look at some of the Tetris variants that people have programmed.

One of the things that lingered in my mind was the idea that all Tetris pieces are made up of four 1x1 blocks.  I've played some variants over the years (many of them official) that did some other things with these four blocks, like allow for corner-to-corner connection (unacceptable!) instead of strict face-to-face connection, but none to my recollection that changed the standard use of four 1x1 blocks per piece.

So what would happen if we changed around this simple building block (haha) of the Tetris franchise?

The simplest Tetris game would be a situation where each piece was made from one 1x1 block.  When I say simplest, I'm not sure I can express that enough.  You just get the same piece over and over, and try to build lines with it.  It's basically two-dimensional Minecraft where the pieces fall from the top and sometimes disappear.

The two 1x1 block case is hardly different, actually.  There's still just one piece, though at least now rotation matters in game.  Not that much, though.

The three 1x1 block situation starts to get a little more interesting.

You still only end up with two distinct pieces - a hooked piece and a straight piece.  It might actually make for a fairly interesting (if not somewhat simpler) game.  Tetris Jr., perhaps.  Someone code this.

A situation with four 1x1 blocks is the Tetris we know and love, and produces seven pieces.

You should be familiar with these, but you can also see that they're basically just an extension of the pieces in the three 1x1 situation.  You can add a 1x1 block to the first piece (in the three 1x1 case) to make the square (O) block.  You can also add a 1x1 block to that piece to make the S, Z, J and L pieces.  You can make the T out of any of the pieces, but the only way to make the straight (I) piece is to add on to the straight piece from the prior set.  It's a rather simple but interesting point.

So we already have a pretty interesting set of numbers here.  The first two cases result in a single piece, then we move to two, then to seven.  We're more than doubling with the addition of one more 1x1 block because each piece already able to be made can produce a number of new pieces.  The more complex those pieces, the more places a block is likely to produce a new unique piece when placed.

Let's see if we can build a set of Tetris pieces with 5 1x1 blocks.  By that I mean, I'm going to spend some time doing that in Excel, and the next thing you'll see is that completed.

So there you go.  That might have seemed quick for you, right?

I worked each piece separately to make sure I was covering all bases, and didn't create duplicates within the same base piece (from the four 1x1 level).  I shaded pieces red if they duplicated a piece already made by a previous base piece.  That leaves us with 18 unique pieces, which we can see a bit clearer in this picture.

There you go.  Someone, make this game.

There are two things that stand out to me.

First off, there's a lot more pieces, but still only one straight piece.  Since it simply is what it is (all the 1x1 blocks you have to work with, in a line), there's only ever going to be one while the rest of the pieces keep expanding.  If you thought you were waiting a long time for a straight piece in the four 1x1 version you'd hate a version like this.

You could look at it this way:

1x1 blocks
I pieces
Percent of whole
1 of 1
1 of 1
1 of 2
1 of 7
1 of 18

That's only going to get worse, though I'm not going to go past five 1x1 blocks given how much more work the six 1x1 case is going to be.

The second thing that stands out to me, though, is how close some of these pieces look to actual letters.  There are also 18 of them, and while some of the duplicates fail the rotation test in Tetris, they would look distinct enough on paper.

In fact, we'd only need eight reflections to get up to 26, which is a pretty interesting number because at that point we can build a substitution cipher with the English language.  So...let's do that.

I didn't really expect to end up with a substitution cipher when I started this post, but I suppose time makes fools of us all.

The nice thing about this is that each letter can fit in a 4x4 square, allowing for even further ciphering by expressing those letters not as letters but as a string of numbers.  Off the top of my head you could easily do that one of two ways.

The first would be expressing a letter as a string of numbers based on which squares were filled in.  In that way, 'a' would be 6/9/10/14/15, or 69101415.  The information can be parsed out without explicit spacing due to the lack of any letters in the cipher using the '1' square.  If there's a 1 in the number it means that it - and the next number following - are part of a two digit number.  In that way you can easily break 69101415 into 6, 9, 10, 14, 15.

The numbers also don't need to be in order, so the letter would be just as preserved written as 10149156.

Each letter could also be written as a 16 digit binary number (realistically less if we figured out which squares were never used).  In that way, 'a' would be 0000010011000110.  If you read my post on binary math you know we could easily translate that number into base 10 and come up with 1,222.

I think I'll revisit this one in a few weeks, as I think there's some other stuff we could do with this.  For now, though:

1 comment:

  1. Hey! I like this post. I had been wondering about shapes with 5 1x1 cubes (staring at the bathroom tile). Hadn't put anything to paper yet but I thought a Tetris game with all the possible shapes would be interesting.

    It seems at least one game has been made, playable online here:

    I think all the 5-shapes that you described are in the game.