Computer Science Canada Shortest Tetris Challenge |
Author: | zylum [ Fri Feb 01, 2008 12:24 pm ] |
Post subject: | Shortest Tetris Challenge |
OK, so there's been a few tetris submissions in the turing forums, some of which had comments relating to how long a tetris program should be. Thus I propose a challenge: program tetris in as few lines as possible. Rules: 1) Your program must more or less conform to the standard tetris rules outlined in section 5 here 2) The official line count will be the number of lines after hitting F2 in the turing environment 3) You may post your code here or you may PM me with your submissions 4) Deadline is Sunday February 10th, 2008 at midnight Bits will be awarded based on how many lines your program is. To make things more interesting you have a choice: Bits = round (10000 / max (lines - 50, 1)) - 50 or Bits = round (1000 / max (lines - zylumLines + 1, 1)) I suppose other languages could be allowed, though the graphics wouldn't be as easy. That's about all for now. I look forward to some creative solutions! BTW here's my submission. I will post the password to the source once the contest is over... |
Author: | Clayton [ Fri Feb 01, 2008 12:28 pm ] |
Post subject: | RE:Shortest Tetris Challenge |
Is there a character limit per line? |
Author: | zylum [ Fri Feb 01, 2008 12:42 pm ] |
Post subject: | RE:Shortest Tetris Challenge |
Well if the lines are too long, they are wrapped after hitting F2. If you are referring to languages other than turing, then no, there is no line limit but standard coding conventions should be used. |
Author: | fishtastic [ Fri Feb 01, 2008 1:20 pm ] |
Post subject: | RE:Shortest Tetris Challenge |
I am in! since exam has been delayed till monday i will spend some time changing my code. current lengh is around 400 with all the extra features now let me get rid of them XD |
Author: | fishtastic [ Fri Feb 01, 2008 11:56 pm ] |
Post subject: | Re: Shortest Tetris Challenge |
here it is, still very long. it looks like i can only get something like 10 bits. Is that all the features i need? |
Author: | StealthArcher [ Sat Feb 02, 2008 12:35 am ] |
Post subject: | RE:Shortest Tetris Challenge |
If I decide to try this, being relatively horrible at tetris, and at game making in general, what is the limitation of external files? |
Author: | zylum [ Sat Feb 02, 2008 1:47 am ] |
Post subject: | RE:Shortest Tetris Challenge |
fishtastic> your board is only 8x18.. Also, your controls seem a bit sticky at times, and at other times over responsive (ie rotates a few times from pushing up once). Standard tetris says "All inputs take effect on the rising-edge of the positive input (i.e., on button press, as opposed to button release)" Other than that, everything seems to be in good shape ![]() StealthArcher> What do you mean external files? If your source is divided amongst several files, then the sum of the line counts will be the total line count.. |
Author: | StealthArcher [ Sat Feb 02, 2008 1:54 am ] |
Post subject: | RE:Shortest Tetris Challenge |
I mean, using files to store data (numbers etc.), not source code. |
Author: | zylum [ Sat Feb 02, 2008 3:16 am ] |
Post subject: | RE:Shortest Tetris Challenge |
Lets keep it to 1 file as I stored all my data in my source code.. |
Author: | fishtastic [ Sat Feb 02, 2008 9:29 am ] |
Post subject: | Re: RE:Shortest Tetris Challenge |
zylum @ Sat Feb 02, 2008 12:47 am wrote: Also, your controls seem a bit sticky at times, and at other times over responsive (ie rotates a few times from pushing up once). Standard tetris says "All inputs take effect on the rising-edge of the positive input (i.e., on button press, as opposed to button release)"
you mean each time you press a key the block should only rotate/move once?? how do you do that in turing? ![]() well i cound but if i make a extra variable to make sure the key stops then it will take even more lines. |
Author: | fishtastic [ Sat Feb 02, 2008 9:55 am ] |
Post subject: | RE:Shortest Tetris Challenge |
I changed from input.keydown to getchar. now every key does something. and it will repeat if you hold down for i while. it says "When a button press occurs, this counts as a request. Holding a button down beyond a certain time may result in the "auto-repeat" feature of a keyboard, generating new button presses -- but this feature is external to the game engine. " so i guess its ok. |
Author: | Tony [ Sat Feb 02, 2008 2:27 pm ] |
Post subject: | Re: RE:Shortest Tetris Challenge |
fishtastic @ Sat Feb 02, 2008 9:29 am wrote: how do you do that in turing?
![]() When we are talking about input edges, or button states, there are 4 for each button. It's tracked over two frames -- that is, where the button was last time through the loop, and where it is now. This generates 4 unique possible states: UP UP -- the button is up DOWN DOWN -- the button is held down UP DOWN -- the button has just be pressed down DOWN UP -- the button has just been released up In Turing you would copy the state of the keyboard into the "old_state" variable just before calling Input.KeyDown() |
Author: | fishtastic [ Sat Feb 02, 2008 2:58 pm ] |
Post subject: | Re: Shortest Tetris Challenge |
Here it is! my final version. This is the shortest I can do. And i think i fixed all the problems. I was being very cheap while coding this. I was changing all "const" to actual number, all 2 layer for loop to 1 layer div/mod for loop. I had a lot of fun making this and being cheap. hopefully, Zylum did not do the same thing. ![]() you can still play the game Anyway. i will tell everyone the password for code on the final day as the rule said. |
Author: | Clayton [ Sat Feb 02, 2008 4:03 pm ] |
Post subject: | RE:Shortest Tetris Challenge |
Zylum probably did his in 25 lines. |
Author: | fishtastic [ Sat Feb 02, 2008 4:13 pm ] |
Post subject: | Re: RE:Shortest Tetris Challenge |
Clayton @ Sat Feb 02, 2008 3:03 pm wrote: Zylum probably did his in 25 lines.
what?? in turing?? ![]() ![]() ![]() ![]() ![]() That is not possible. no way! If he did it in 25 lines then the equation will not be 1000/(yourline - zylumline) I say it took him at least 50 lines. |
Author: | Tony [ Sat Feb 02, 2008 4:47 pm ] |
Post subject: | RE:Shortest Tetris Challenge |
If you take out the exact specifications of "standard tetris", zylum could make "a tetris" in 20 lines. |
Author: | ericfourfour [ Sat Feb 02, 2008 5:31 pm ] | ||||||
Post subject: | Re: Shortest Tetris Challenge | ||||||
The file is 2734 Bytes. Each character is 1 Byte. To find out how many lines Zylum used you need to guess the average number of characters per line.
Let's try 32 chars / line:
Let's try 80 chars / line:
My guess is 34 <= zylumLines <= 85. |
Author: | Tony [ Sat Feb 02, 2008 6:55 pm ] |
Post subject: | RE:Shortest Tetris Challenge |
Keep in mind that there is a datafile in there as well. Also, there's a lot of variance in "characters per line". loop / end loop is 2 lines and only 11 characters. |
Author: | zylum [ Sat Feb 02, 2008 9:48 pm ] |
Post subject: | Re: Shortest Tetris Challenge |
Clayton @ Sat Feb 02, 2008 5:03 pm wrote: Zylum probably did his in 25 lines.
I was hoping to ![]() ![]() You guys over estimate me a bit ![]() fishtastic> I'm glad you enjoyed the contest ![]() As for your program, it's a lot better! Couple of small details though.. The pieces don't generate at the proper place (ie [6, 20]) and some of the pieces don't rotate properly (the I piece for instance), but these problems should be trivial to fix at this point. So far fishtastic is the only submission. Looking forward to seeing more ![]() BTW here's a slightly shorter version of mine... |
Author: | Clayton [ Sun Feb 03, 2008 11:03 am ] |
Post subject: | RE:Shortest Tetris Challenge |
I was kind of being a bit sarcastic, but you get my point ![]() |
Author: | fishtastic [ Sun Feb 03, 2008 2:07 pm ] |
Post subject: | Re: Shortest Tetris Challenge |
here. my newer version. few lines shorter. and i think i fixed the rotation. I will post the code near the of this challenge. since i might change my code again. ![]() |
Author: | ericfourfour [ Sun Feb 03, 2008 7:28 pm ] | ||||||||||
Post subject: | Re: Shortest Tetris Challenge | ||||||||||
If anyone wants to know a shortcut for doing rotations: As long as you design your pieces the way the site Zylum linked to did, this should be no problem. The formula for rotating a point around the origin is:
Since we are only rotating counter-clockwise, the angle is: 90 degress (or pi / 2 radians).
Since: sin 90 = 1 and cos 90 = 0:
or:
An example of this in Turing:
If you want to rotate clockwise use theta = 270 (or 3 * pi / 2 radians). You will also have to compensate for pieces that do not rotate or only rotate once. |
Author: | fishtastic [ Sat Feb 09, 2008 1:23 pm ] | ||
Post subject: | Re: Shortest Tetris Challenge | ||
Here is my code. It seems like no one else is doing this challenge, also i don't think i can make it shorter. although I could use some really meaningless methods (such as putting all variables in one variable using div/mod). But even if that makes the program having lesser lines, it wont really make the program smaller in size. I think the contest would be better if it is marked based on the size(in bytes) instead of line number. anyway. the program is 80 line (by that i mean after f2 and does not generate a not enough memory for indent message.) I don't think i will have time to work on this since it ends on sunday and i have quite lot of things to do this week. I would really like to see how zylum did it. zylum's is almost 1kb smaller (still looks impossible ![]() ![]() ![]()
|
Author: | zylum [ Mon Feb 11, 2008 4:25 am ] |
Post subject: | RE:Shortest Tetris Challenge |
OK so the contest is closed with a total of one submissions ![]() BTW I'm quite impressed you made it so short ![]() |
Author: | Tony [ Mon Feb 11, 2008 10:32 am ] | ||
Post subject: | RE:Shortest Tetris Challenge | ||
Awesome. I quite like this line, for initializing that 2D boolean array:
Nice! ![]() |
Author: | fishtastic [ Mon Feb 11, 2008 3:30 pm ] |
Post subject: | Re: RE:Shortest Tetris Challenge |
zylum @ Mon Feb 11, 2008 3:25 am wrote: OK so the contest is closed with a total of one submissions
![]() I dont really think mine is short enough to compare with yours. first one please ![]() BTW I remember seeing 1kb tetris in flash before, just cant find the site anymore.... |
Author: | Clayton [ Mon Feb 11, 2008 3:44 pm ] | ||
Post subject: | RE:Shortest Tetris Challenge | ||
I'll take option one, as that results in 9950 bits. |
Author: | Tony [ Mon Feb 11, 2008 3:47 pm ] | ||
Post subject: | RE:Shortest Tetris Challenge | ||
gg Clayton |
Author: | Clayton [ Mon Feb 11, 2008 3:48 pm ] |
Post subject: | RE:Shortest Tetris Challenge |
but that way you don't get my gloating-ness, also, what the hell does true/false mean to the end user? ![]() |
Author: | StealthArcher [ Mon Feb 11, 2008 5:34 pm ] | ||
Post subject: | RE:Shortest Tetris Challenge | ||
|
Author: | zylum [ Mon Feb 11, 2008 7:04 pm ] | ||
Post subject: | Re: Shortest Tetris Challenge | ||
Alright, here's my code.. Only marginally better than fishtastic's at 73 lines ![]() ![]()
I wonder if it's possible to make it <= 50 lines ![]() fishtastic> You have been awarded 283 bits |