Drawing arbitrary 8-bit images by playing Tetris

Holy. Crap.

Michael Birken lays out, in detail, a method for teaching a computer to draw arbitrary 8-bit images by playing Tetris, strategically deploying blocks of various colors to cause exactly the picture you want to emerge. The method is (as you'd imagine), starkly terrifying in its complexity, but the video speaks for itself.

The algorithm converts pixels from a source image into squares in the Tetris playfield, one row at a time from the bottom up. To generate an individual square, the algorithm assembles a structure consisting of a rectangular region fully supported by a single square protruding from the bottom. When the rectangular region is completed, its rows are cleared, leaving behind the protruding square. Three examples of the process appear below.

The algorithm can also generate multiple squares with a single structure as shown below.

During construction of a row, all of the squares produced by this method must be supported. In the images above, the generated squares are supported by the floor of the playfield. However, if an arbitrary row contains holes, it may not provide the support necessary for the construction of the row above it. The algorithm solves this problem by constructing a flat platform on top of the row with holes. In the animation below, a platform is built above a row comprising of a single red square. The platform is a temporary structure and inserting the final piece removes it.

Tetris Printer Algorithm (via Hacker News)


  1. Thank god, an algorithm.  I was about to jam my controller up my nose and into my brain in despair because, how the heck do you compete with that?

    1. Try finding the frame(s) with a score of 72200. Those pixels are supported by three almost-complete rows that will be eliminated with an elbow block on the right.

      1. Oh weird, I guess I never noticed that individual pieces don’t continue to fall by gravity. Obvious in retrospect.

  2. That’s the depest Tetris I’ve ever seen. I think. It’s been a long time. But it’s like 40 levels deep, is that normal?

Comments are closed.