There was recently (a few years back) some buzz on programming websites about an implementation of Tetris in 140 Bytes. ...
It turns out that although it is small, it is a simplified version of Tetris, and not even a complete implementation. Only the core logic function fits in 140 bytes of Javascript. To actually run it, you need another ~840 characters of HTML.
We can do better!
This challenge is to implement a complete version of "Binary Tetris" in as few tweets as possible.
Binary Tetris Rules:
- The program must display a playing field containing at least 5 columns and 6 rows of cells.
- Any method of display may be used, as long as the blocks and the edges of the field are clearly marked.
- There must be at least two types of blocks:
#
and##
. Additional block support such as###
or angle blocks shaped like an L will get upvoted by me :P and the most complete game of binary tetris (the most blocks like the original and rotation features) will win my happiness and a possible bounty up 50 rep. - New blocks are added to the field in the top row, and one block cell must occupy the center column.
- Blocks descend towards the bottom row at a fixed rate. Blocks must descend even without user input.
- When blocks touch the bottom of the field or a lower block, they stop falling and are fixed in place. A new block is added.
- When all the columns in the row are filled with blocks, the row is emptied, and all the fixed blocks above drop down one row.
- The program must respond to keypresses. There must be 3 unique keys that perform the following functions
- shift current block left 1 column
- shift current block right 1 column
- shift current block down 1 row
- Each tweet may only have 140 characters. Using multi-byte characters that can be put in tweets is allowed.
The rules for what can be in a tweet is simple. If you can tweet it you can use it.
Interpreted languages follow the same rules. Each section must follow the specs. As long as no run time errors occur (and the rest is valid following the specs) your answer is valid Golfing Rules:
Because the original implementation was "tweetable", this challenge requires the same. Entries must be able to be transmitted as a series of tweets (lines of 140 characters or less).The first tweet must contain the name of the compiler/interpreter, the name of the program, and any command line arguments
- it will be saved as file "P0"
- The following N tweets must contain the program as a series of lines.
- Each tweet will be stored in a file with the name T<n>, where n is 1..N
- Each line will be added to the previous lines and compiled or interpreted. It must produce a valid object file or program.
- The program does not need to be functional until the last line is added.
The program will be run in the following manner (pseudo-bash)
interp,prog,args = split P0 /\s/ touch $prog for file in ./T* do cat $prog file > $prog $interp $prog $args die("FAIL") if $? #detect error done
The interpreter must be a commonly available executable program that does not already implement Tetris.
Scoring:
Fewest Tweets, including P0. Ties broken by largest number of spare characters (140 * num tweets - total character count).
Example Entries
chrome a.htm
<html><div id="output"></div></html>
<script>cool java script here</script>
Score = 3 (334 spare)
cc a.c ;a.out
main(){/*cool prog here*/}
Score = 2 (241 spare)
tetris
Score = 1 (134 spare) if it were legal, which it's not
Special thanks
I was allowed to post this by Ashelly's consent here