Slim, Fast: Tetris & Snake In 140 Bytes

By Alec Meer on February 21st, 2012 at 10:57 am.

Inspiring screenshots of our time

This is amazing! Well, the game itself – a hobbled, ASCII-esque version of Tetris with only two block types – isn’t amazing, but the fact that it comprises just 140 bytes is. 140 bytes in this instance also means 140 characters, so essentially this is a working game you could post on Twitter.

Play it in your browser here, then come back here and marvel that the below is all that’s involved:

function(a,b,c,d,e){return d+=c,
e=a|b< parseInt((a|b< .replace(/v/,”"),d),b=new Date%2?1:3),
[a,b,d,e]}

That’s Javascript, so it’s calling up various higher functions and… oh, I’m too stupid to understand, but I know that it’s damned clever. Admittedly there does appear to be some cheating going on, in that input and display are handled separately: you can comb through the code and discussion here.

It’s part of a project/contest called 140byt.es, which has also generated a similarly svelte and smart take on Snake.

These people. They are clever people. I am not. I feel bad now.

__________________

« | »

, , , .

25 Comments »

  1. benjymous says:

    Sadly it’s just the update function that’s 140 bytes. The whole javascript source for the code that includes the important stuff like reading the keyboard, and displaying stuff on screen is closer to 1kb.

    I can fit all of tetris into one character. Here it is:

    “T”

    (Don’t worry about all the stuff that’d actually make that work, it doesn’t count)

  2. max pain says:

    “The main logic to move blocks, detect collision, assign new blocks, remove full lines and render the layout are included. Excluded are keyboard controls and the final rendering.”

    So while technically not a whole game, it’s still impressive. The step by step explanation on project page is an interesting read.

  3. Matt says:

    Holding down the right arrow key makes that game of Tetris do some strange things.

  4. AndrewC says:

    I had my breakfast in only 20 bytes.

  5. Rikard Peterson says:

    It reminds me of TWIFcomp – a competition for IF games where the source code had to fit in a twitter message. http://blog.templaro.com/?page_id=118

  6. Zanchito says:

    Whatever happened to the demoscene? They used to have 256byte game/demo competitions. With EVERYTHING in, no need for a JS interpreter, as they were straight assembly. Some really talented and creative people and projects there!

  7. Vagrant says:

    It’s not even Tetris! The fundamentals are not even there. The game doesn’t have the long I-block tetrimino. Without that you can’t clear 4 lines. Clearing 4 lines is called a Tetris. Also, all the blocks aren’t made up of 4 smaller blocks.

    I may play too much Tetris. Anyone want to come over & play on my Tetris arcade cabinet?

  8. BobsLawnService says:

    That is a clever little function but hardly a 140 byte game.

Comment on this story

XHTML: Allowed code: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>