# Using Tetris Like MS Paint

Check out Samus looking boss in this pixelated image. Who would have thought of using Tetris as a canvas for these types of graphics? Coming up with the original idea of strategically clearing and leaving Tetris pieces to end up with what is shown above is hard enough. But how in the heck do you implement the algorithm that generated this programmatically?

First off, two thing should not be surprising about this. It wasn’t manually generated during normal gameplay. That would be beyond savant level. The other thing to note is that the order in which pieces occurred was not random, but strategically calculated by the algorithm. The challenge is not only to occupy and clear the correct pixels, but to make sure the correctly colored pieces remain.

You need to see the fast-motion video embedded after the break to fully appreciate the coding masterpiece at work. We’re not going to try to paraphrase how the algorithms functions, but get comfy with the link above which walks through all of the theory (in addition to supplying the code so you can try it yourself).

[via Reddit]

## 11 thoughts on “Using Tetris Like MS Paint”

1. pff says:

“The other thing to note is that the order in which pieces occurred was not random, but strategically calculated by the algorithm.”

boooooooooooooooooring

1. I thought so to at first. But I followed the link anyhow… I already read every other post of the day.

This is actually impressive, don’t write it off because the pieces are predetermine.

2. If you knew the piece-generating algorithm, I wonder if you could plan ahead based on knowing the future…

2. Spellchecker says:

Baxter was doing this sort of TAS back in 2011, just not as well documented.

1. timbo says:

Thanks for sharing this. Using the actual tetris game is more impressive to me than the simulation.

3. Frinton says:

Neat, it looks like an excellent programming puzzle.
Now I wonder how one could do it using the least possible amount of pieces…

4. Lior says:

I wonder if, given an sufficiently high Tetris “field” (I’m talking hundreds or even thousands blocks high), you could do this with (fair) randomized pieces.

5. spike says:

6. a b c d e f g says:

The Tetris play field is supposed to be 10 blocks wide.

So, not random pieces, and not the standard play field.

While this reduces it down to a definite NON-TETRIS hack, it’s more than I could do in a hurry.

7. NewCommentor1283 says:

at last im liberated from the label of crazy!

i just KNEW there was a pattern.
it’s what ive been telling people for years…
you should see me play, i use the button that drops the piece
ALL the way down instantly and play a LOT faster then most people.

the first few levels go much faster that way.
and subconciously knowing the next 3 pieces
helps with beating other people’s top scores too.

too bad it takes days of playing several hours each
to warm up to the patterns. once your there,
you can trash anybody’s highscore list in less then an hour.

KUDOS FOR BEING ABLE TO CALCULATE THE PATTERENS!
i always thought about how hard that would be to do.
it would be eaiser to teach something HOW to learn.

PS: im talking about tetris with ONLY one next-piece displayed.

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.