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)

    • kregg says:

      You did it wrong: “┴”
      That way, the bottom row will be erased, and you get more points.

    • Alec Meer says:

      I can fit all the emotions you have ever felt into just two characters:

      :(

    • The Sombrero Kid says:

      every game every made collapses to a single function call, you got played, you should probably check this stuff with a programmer before posting it, not me though, cba :P

      I know this thread is going to be filled with whiners like me pointing out it’s not news, so to offset that i’d like to say keep up the good work in general.

    • Jeroen D Stout says:

      I, too, am enraged they did not include the Chrome code in the 140B! How dare they call it a 140B game if Windows 7 is more than 2 gigabyte?! Also, my BIOS is larger than 140B already?! I presume they also did not take into account that to actually transfer 140 characters over the internet you need more than 140B because of default information loss?

      Gah, I am so ENRAGED I could breathe FIRE.

      It reminds me of http://blog.wolfram.com/2011/12/01/the-2011-mathematica-one-liner-competition/.

    • benjymous says:

      Far more impressive is this:

      http://js1k.com/2010-first/demo/730

      A proper game of tetris, including sound, done in 1kb of javascript

  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. Bruce_Z says:

    Remember the FPS GAME in 96KB?

    • Llewyn says:

      96KB isn’t really so impressive to anyone who grew up with a C64 or a Spectrum.

      Also, bad form to link via an advertising portal rather than directly.

    • SquareWheel says:

      Very bad form.

    • Mo says:

      @Llewyn:
      Let’s gloss over the fact that kkrieger is a little more sophisticated than your average C64 or Spectrum game, eh?

      Official link here btw: http://www.theprodukkt.com/kkrieger

    • The Sombrero Kid says:

      96KB isn’t reductive enough for people who played cup-ball! or hoop-n-stick.

  4. Matt says:

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

  5. AndrewC says:

    I had my breakfast in only 20 bytes.

  6. 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

  7. 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!

    • Salt says:

      It still exists. Pouët.net has most releases, with executables and usually screenshot and video if it doesn’t play nice on your computer.

  8. 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?

    • kavika says:

      Agreed. If it ain’t tetromino, it ain’t really tetris:

      http://en.wikipedia.org/wiki/Tetromino

      There’s a “tetris friends” site that has 2 player scored rank scaling tetris so you can match up to same-caliber opponents online. Saw it on a league of legends stream the other night and spent a couple hours playing it. good stuff :)

    • emertonom says:

      More to the point, you can’t rotate the pieces. Even so, pretty neat.

  9. BobsLawnService says:

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