Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

We are sorry to see you leave - Beta is different and we value the time you took to try it out. Before you decide to go, please take a look at some value-adds for Beta and learn more about it. Thank you for reading Slashdot, and for making the site better!

Javascript Game of Tron In 226 Bytes

timothy posted more than 2 years ago | from the tattoo-sized dept.

Chrome 115

Have you upgraded your hardware to play something beefier than 140-byte Tetris? New submitter alokmenghrajani writes with "a detailed view of how we size-optimized a game of Tron to just 226 bytes." It's also optimized for Chrome, and very fast.

Sorry! There are no comments related to the filter you selected.

1KB Chess For The Sinclair (5, Informative)

TheGoodNamesWereGone (1844118) | more than 2 years ago | (#39466525)

1KB Chess for the Sinclair still has that beat.

Re:1KB Chess For The Sinclair (5, Informative)

lobiusmoop (305328) | more than 2 years ago | (#39466701)

Actually it was only 672 bytes - the 1024 byte memory had to include the screen memory also, much like shared video memory today - could take up to 768 of the 1024 bytes for a full 32x24 screen! (the chess game only used an 11-line screen for the board etc)

And it's even considered by some to be the greatest program ever written. [kuro5hin.org]

Re:1KB Chess For The Sinclair (3, Interesting)

Anonymous Coward | more than 2 years ago | (#39467107)

And what about the 20 MB browser and all other cram below it? I can do a 3D FPS in 0 lines of code by just inserting a DVD into my PS3! Yay for me!

Re:1KB Chess For The Sinclair (-1)

Anonymous Coward | more than 2 years ago | (#39472895)

Oh what great fun playing a 3D FPS on a PS3 without a mouse!

Re:1KB Chess For The Sinclair (0)

Anonymous Coward | more than 2 years ago | (#39471325)

As far as I can tell it's considered to be the greatest by one single person.

Re:1KB Chess For The Sinclair (1)

bargainsale (1038112) | more than 2 years ago | (#39466907)

There is a Befunge program for chess which is 1.5KB, and plays legally at least. Proof either of the great ingenuity of the human race or of the fact that some people have way too much time on their hands.

Re:1KB Chess For The Sinclair (1)

Joce640k (829181) | more than 2 years ago | (#39467227)

Just tried it, it works fine in Firefox 13...

Re:1KB Chess For The Sinclair (1)

Luckyo (1726890) | more than 2 years ago | (#39468397)

It works even on firefox 3.6.x

Re:1KB Chess For The Sinclair (1)

hcs_$reboot (1536101) | more than 2 years ago | (#39467611)

ie6 also was written within 1k. the thing is, nobody seems surprised.

Re:1KB Chess For The Sinclair (2, Insightful)

hairyfeet (841228) | more than 2 years ago | (#39469501)

Not to mention this is NOT "Tron" this is just a variation on slither. These don't even look like light cycles they are just dots. Lame. And since when do we not count all the overhead of the browser? I'm sure you could get a 5Kb checkers game by using all the existing code in ubuntu or Win 7 but we wouldn't say that it was really a 5Kb checkers game would we?

Re:1KB Chess For The Sinclair (1)

bryan1945 (301828) | more than 2 years ago | (#39471211)

And the "Tron" game I remember had a few other games, to boot.
Cool project, bad naming.

Black squares... (0)

Anonymous Coward | more than 2 years ago | (#39466531)

....are really fast.

Damn. (1)

x0d (2506794) | more than 2 years ago | (#39466557)

It's Chrome-only.

Re:Damn. (1)

cynyr (703126) | more than 2 years ago | (#39466577)

I'm running chrome ( Version 19.0.1068.0 (0) ) and i get this nice fast black square....

Re:Damn. (1)

houstonbofh (602064) | more than 2 years ago | (#39466617)

So I don't know weather to be pissed that it is not standards based and working in Firefox, or pissed because it is slashdotted...

Re:Damn. (0)

Anonymous Coward | more than 2 years ago | (#39467593)

I know snow when I see it, though.

Re:Damn. (1)

Anonymous Coward | more than 2 years ago | (#39468553)

working fine on 19.0.1074.0
press j k i l

Re:Damn. (2)

chrismcb (983081) | more than 2 years ago | (#39470201)

Apparently they don't consider "how to play the game" as part of the game. Hit i,j,k,l (well any key really)

Re:Damn. (0)

Anonymous Coward | more than 2 years ago | (#39466599)

worked fine in safari. (although control lag wasn't fun)

Re:Damn. (1)

Anonymous Coward | more than 2 years ago | (#39466607)

Works on Firefox 11 just fine.

Re:Damn. (1)

hobarrera (2008506) | more than 2 years ago | (#39466623)

No it's not. It works fine under firefox. I'd write down what version I'm running, but I can't type that fast.
You can also look at the code, there's nothing non-standard in it.

Re:Damn. (4, Informative)

TheRaven64 (641858) | more than 2 years ago | (#39466635)

Works fine in Safari. That said, if you press a key other than ijkl it does something random. I assumed wasd would work, and was very confused until I read the instructions. It's also single player, so you basically drive around until you hit your own wall - there's no way of winning. It's more a drawing program with a crappy UI than a game. Making it only 226 bytes of source isn't that impressive, it's basically:
  • Change direction if key is pressed
  • Test if pixel next in that direction is white, if so exit
  • If not, set it to white, set current location to that address
  • Repeat.

I wouldn't be surprised if you could write the same game in under 226 bytes of Z80 or 6502 assembly, so doing it in a high-level language seems much less impressive.

Re:Damn. (1, Interesting)

Anonymous Coward | more than 2 years ago | (#39466997)

Under 226? instead of being a critical asshole, that "someone" who sits outside every event and just points, please post your code that does just that. Or, give people a fucking break and realize that pushing boundaries like this is what science, and computer science, is all about. Take off your cynical sunglasses and watch the world become so much more clear. Or not.

Re:Damn. (-1)

Anonymous Coward | more than 2 years ago | (#39467787)

Science is also about being able to proof what you claim and this demo is not an implementation of Tron.

Re:Damn. (0)

dittbub (2425592) | more than 2 years ago | (#39469505)

you're right. its like that guy who said he got monkeys to write Shakespeare, he didn't.

Re:Damn. (0)

tibit (1762298) | more than 2 years ago | (#39470475)

1. Computer science has got zilch to do with computers. It's a field of mathematics.

2. This "tron" program does not push the boundaries of any science.

3. Neither is it some a software engineering feat.

It's a hack with some neatness to it, that's about it.

Re:Damn. (-1)

Anonymous Coward | more than 2 years ago | (#39470587)

Hehehehe. You're funny. I like you.

Re:Damn. (1)

dotancohen (1015143) | more than 2 years ago | (#39467367)

Works fine in Safari. That said, if you press a key other than ijkl it does something random. I assumed wasd would work, and was very confused until I read the instructions.

I use Vimperator, you insensitive clod! Even ijkl don't work for me, and my fingers kept trying hjkl anyway!

Re:Damn. (1)

borrrden (2014802) | more than 2 years ago | (#39466663)

Works fine for me in Firefox 12.0

Re:Damn. (1)

x0d (2506794) | more than 2 years ago | (#39466737)

oh, my mistake. I saw that chrome logo, tried it in opera and it didn't work. I'm also too lazy to open safari just for that.

Re:Damn. (1)

NemosomeN (670035) | more than 2 years ago | (#39467037)

Saw the Chrome logo, so I tried it in Opera. I'm too lazy to open Safari, so I just assumed it didn't work in Firefox. Sounds logical.

Re:Damn. (1)

Ksevio (865461) | more than 2 years ago | (#39467193)

Well it works fine in Opera 12.

Re:Damn. (1)

bvimo (780026) | more than 2 years ago | (#39467365)

and Opera 11.61 (although it is a little fast).

Version: 11.61
Build: 1250
Platform: Linux
System: x86_64, 3.0.0-16-generic

Re:Damn. (1)

Luckyo (1726890) | more than 2 years ago | (#39468409)

Firefox 3.6.x (latest 3.6 version) runs it fine.

Note that code itself suggests that game will not start until you press one of the four control buttons.

Re:Damn. (1)

antdude (79039) | more than 2 years ago | (#39468607)

It worked OK in my old Mozilla's SeaMonkey v2.0.14 web browser. ;)

Neat, but (1)

Anonymous Coward | more than 2 years ago | (#39466563)

keyup instead of keydown makes the game play like junk. Much more apparently unresponsive.

Re:Neat, but (0)

Anonymous Coward | more than 2 years ago | (#39466587)

Pressing right made it go down. I'm totally not getting the controls. I'd say this is pathetic and not something to crow about.

Re:Neat, but (1)

TheRaven64 (641858) | more than 2 years ago | (#39466647)

The arrow keys that it uses are ijkl. Any other key will make it go in a random direction.

portability (1)

Anonymous Coward | more than 2 years ago | (#39466579)

Tried it in ie9. It simply doesn't work.

Re:portability (4, Interesting)

hobarrera (2008506) | more than 2 years ago | (#39466633)

It works on chrome and firefox. This isn't a portability issue: normally developers add huge amounts of code to support IE. If it needs tweaking for IE, it would probably be 50% larger.

Re:portability (-1)

dave420 (699308) | more than 2 years ago | (#39466679)

"Huge amounts"? Hardly. I'm absolutely no fan of IE, but its not as bad as you seem to think.

Re:portability (0)

Anonymous Coward | more than 2 years ago | (#39466775)

Works fine on Opera 11.61 as well.

Re:portability (0)

Anonymous Coward | more than 2 years ago | (#39466859)

All you need is Runtime.run

Re:portability (-1)

Anonymous Coward | more than 2 years ago | (#39467209)

Why do people love Chrome so much? It's proprietary software and comes from a company with shoddy business ethics. Hint: Chrome for Android is not, and never will be, open source. And don't count on seeing Chromium for Android any time soon.

Stick to Firefox, noscript and ghostery and you can keep the Google creeps away.

--
mchurch

Re:portability (1)

Phroggy (441) | more than 2 years ago | (#39468623)

Why do people love Chrome so much? It's proprietary software and comes from a company with shoddy business ethics.

Because it's lightweight and fast, it doesn't pop up with an upgrade notice every two weeks, it has a good standards-compliant rendering engine, and Mozilla desperately needs the competition.

Re:portability (1)

theweatherelectric (2007596) | more than 2 years ago | (#39469167)

Because it's lightweight

In what sense is Chrome lightweight? Of the five major browsers, Chrome is the second biggest memory consumer [tomshardware.com] and it comes bundled with Flash, which I personally don't have a use for.

Re:portability (1)

tibit (1762298) | more than 2 years ago | (#39470489)

And has a half-decent built-in PDF rendered. I classify chrome as about the only useable alternative to Acrobat Reader other than Apple's preview. The various free readers are quite unfinished in many ways, in comparison.

Re:portability (1)

Jorl17 (1716772) | more than 2 years ago | (#39468999)

You do know that Chromium in itself is open-source, right?

Re:portability (0)

Anonymous Coward | more than 2 years ago | (#39468369)

didn't work in my firefox (10.0)

Re:portability (1)

ShanghaiBill (739463) | more than 2 years ago | (#39469473)

If it needs tweaking for IE, it would probably be 50% larger.

The program uses an HTML5 canvas. So it would need a lot more than "tweaking" to work in IE. It would need a completely different implementation.

But IE 10.0 is supposed to (finally) have canvases.

Re:portability (0)

Darinbob (1142669) | more than 2 years ago | (#39469811)

Actually, does NOT work in my firefox.

But who cares. It just shows that it is highly and amazingly dependent upon the many megabytes of code that it sits on top of. It needs a javascript engine and a browser. You may as well add a byte code that invokes a game of Tron and claim it only needs 1 byte.

Re:portability (1)

hobarrera (2008506) | more than 2 years ago | (#39472297)

That's odd. Maybe you should report this to the dev, with your FF version, platform, etc. I played quite a while with FF and it worked fine. The controls are i,j,k,l, and you *may* need to click the black canvas to focus it.

Controls? (1)

Rinisari (521266) | more than 2 years ago | (#39466713)

I'd love to have another 226 bytes explaining the controls. They don't seem to make much sense...

Re:Controls? (3, Informative)

Anonymous Coward | more than 2 years ago | (#39467067)

IJKL instead of WASD or arrow keys. It saves space because IJKL is actually in alphabetical order, which makes it a neat modulus away from being the four directions.

A whole web page? Put it in the URI. (-1)

Anonymous Coward | more than 2 years ago | (#39466733)

Chess in a URI. Although I'll admit it's a tad over 226 bytes.

data:text/html,%3Cbody%3E%3Cscript%3Evar%20B,i,y,u,b,I=[],G=120,x=10,z=15,M=1e4,l=[5,3,4,6,2,4,3,5,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,13,11,12,14,10,12,11,13,0,99,0,306,297,495,846,-1,0,1,2,2,1,0,-1,-1,1,-10,10,-11,-9,9,11,10,20,-9,-11,-10,-20,-21,-19,-12,-8,8,12,19,21];function%20X(w,c,h,e,S,s){var%20t,o,L,E,d,O=e,N=-M*M,K=78-h%3C%3Cx,p,g,n,m,A,q,r,C,J,a=y?-x:x;y^=8;G++;d=w||s&&s%3E=h&&X(0,0,0,21,0,0)%3EM;do{if(o=I[p=O]){q=o&z^y;if(q%3C7){A=q--&2?8:4;C=o-9&z?[53,47,61,51,47,47][q]:57;do{r=I[p+=l[C]];if(!w|p==w){g=q|p+a-S?0:S;if(!r&(!!q|A%3C3||!!g)||(r+1&z^y)%3E9&&q|A%3E2){if(m=!(r-2&7))return%20y^=8,I[G--]=O,K;J=n=oE=I[p-a]t=q|E-7?n:(n+=2,6^y);while(n%3C=t){L=r?l[r&7|32]-h-q:0;if(s)L+=(1-q?l[(p-p%x)/x+37]-l[(O-O%x)/x+37]+l[p%x+38]*(q?1:2)-l[O%x+38]+(o&16)/2:!!m*9)+(!q?!(I[p-1]^n)+!(I[p+1]^n)+l[n&7|32]-99+!!g*99+(A%3C2):0)+!(E^y^9);if(s%3Eh||1%3Cs&s==h&&L%3Ez|d){I[p]=n,I[O]=m?(I[g]=I[m],I[m]=0):g?I[g]=0:0;L-=X(s%3Eh|d?0:p,L-N,h+1,I[G+1],J=q|A%3E1?0:p,s);if(!(h||s-1|B-O|i-n|p-b|L%3C-M))return%20W(),G--,u=J;J=q-1|A%3C7||m||!s|d|r|o%3Cz||X(0,0,0,21,0,0)%3EM;I[O]=o;I[p]=r;m?(I[m]=I[g],I[g]=0):g?I[g]=9^y:0;}if(L%3EN||s%3E1&&L==N&&!h&&Math.random()%3C.5){I[G]=O;if(s%3E1){if(h&&c-L%3C0)return%20y^=8,G--,L;if(!h)i=n,B=O,b=p;}N=L;}n+=J||(g=p,m=p%3CO?g-3:g+2,I[m]%3Cz|I[m+O-p]||I[p+=p-O])?1:0;}}}}while(!r&q%3E2||(p=O,q|A%3E2|o%3Ez&!r&&++C*--A));}}}while(++O%3E98?O=20:e-O);return%20y^=8,G--,N+M*M&&N%3E-K+1924|d?N:0;}B=i=y=u=0;while(B++%3C120)I[B-1]=B%x?B/x%x%3C2|B%x%3C2?7:B/x&4?0:l[i++]|16:7;for(a='%3Ctable%20cellspacing=0%20align=center%3E',i=18;i%3C100;a+=++i%2510-9?'%3Cth%20width=60%20height=60%20onclick=Y('+i+')%20id=o'+i+%22%20style='line-height:50px;font-size:50px;border:2px%20solid%20%23dde'%20bgcolor=%23%22+(i*.9&1?'c0c':'f0f')+'0f0%3E':(i++,'%3Ctr%3E'));a+=%22%3Ctd%20colspan=3%20align=left%3E%3Ca%20href='https://wcms.inf.ed.ac.uk/lfcs/events/ian-stark'%3EWeightless%20website%3C/a%3E%3Cbr%3E%3Ca%20href='http://homepages.ed.ac.uk/stark'%3EIan%20Stark%3C/a%3E%3Cth%20colspan=2%3E%3Cselect%20id=t%20style='font-size:20px'%3E%3Coption%3E&%239819;%3Coption%3E%22;document.write(a+%22&%239820;%3Coption%3E&%239821;%3Coption%3E&%239822;%3C/select%3E%3Ctd%20colspan=3%20align=right%3E%3Ca%20href='http://nanochess.110mb.com/chess4.html'%3EChess%20code%20%3Cbr%3E%d3scar%20Toledo%20G.%3C/a%3E%3C/table%3E%22);function%20W(){B=b;for(p=21;p%3C99;++p)if(q=document.getElementById('o'+p)){q.innerHTML='\xa0\u265f\u265a\u265e\u265d\u265c\u265b%20%20\u2659\u2654\u2658\u2657\u2656\u2655'.charAt(I[p]&z);q.style.borderColor=p==B?'red':'%23dde';}}W();function%20Y(s){i=(I[s]^y)if(i%3E8){b=s;W();}else%20if(B&&i%3C9){b=s;i=I[B]if((i&7)==1&(b%3C29|b%3E90))i=14-document.getElementById('t').selectedIndex^y;X(0,0,0,21,u,1);if(y)setTimeout('X(0,0,0,21,u,2/*ply*/),X(0,0,0,21,u,1)',250);}}%3C/script%3E%3C/body%3E

Re:A whole web page? Put it in the URI. (0)

Anonymous Coward | more than 2 years ago | (#39469729)

Could you post this in one of those text sharing sites? Copying this didn't seem to work.

2 player? (5, Informative)

Ambitwistor (1041236) | more than 2 years ago | (#39466735)

It's not really a game of Tron without a competing lightcycle. (Without fruit, it's not really a game of Snake either.)

Re:2 player? (3, Interesting)

Lorkki (863577) | more than 2 years ago | (#39468281)

Nor is it really Tetris without tetraminoes or scoring. Not to berate the effort, but it's a lot easier to downsize something when you drop half of the main features.

Re:2 player? (1)

Misagon (1135) | more than 2 years ago | (#39469181)

The light cycles was only a single stage within the Tron arcade game [wikipedia.org] .
The original "Snake" was Centipede [wikipedia.org] .

Calling this a game of "Tron" is a stretch (5, Insightful)

readandburn (825014) | more than 2 years ago | (#39466785)

It should be called "Drawing-A-Line-In-A-Tiny-Black-Square-With-Terrible-Controls".

Come to think of it, that might make a better movie than that last Tron.

Re:Calling this a game of "Tron" is a stretch (0)

Anonymous Coward | more than 2 years ago | (#39467987)

come to think of it, javascript certainly doesn't make better animation than flash. no wonder the html hype machine has ground to a halt, even on this site.

Re:Calling this a game of "Tron" is a stretch (0)

Anonymous Coward | more than 2 years ago | (#39468127)

A post by guy-who-is-never-happy-about-movies-that-came-out-recently.

Re:Calling this a game of "Tron" is a stretch (1)

readandburn (825014) | more than 2 years ago | (#39469053)

Let me get this straight. In order to be happy with all movies that came out recently, I had to like Tron?

I'd love to hear an explanation of that logic.

Re:Calling this a game of "Tron" is a stretch (0)

Anonymous Coward | more than 2 years ago | (#39469493)

The fellow AC hasn't made so much a logical error as just a foolish one. However, there's a problem with your logic.

Since you're wanting to "get this straight", yes, it is true that "in order to be happy with all movies that came out recently, you had to like Tron", since Tron is one of those movies.

To clarify, let A be the set of all recent movies, so Tron is in A. Let P(x) be the statement that you are happy with the movie x. Then the conversation goes like this:

  • You: ~P(Tron)
  • AC: (for all x in A)(~P(x))
  • You: Let me get this straight. (for all x in A)(P(x)) --> P(Tron).

This final statement is not equivalent to what the AC has suggested. For starters, it is true, whereas the AC's conclusion was, as you suspected, foolish. What you meant was:

You: Let me get this straight. ~P(Tron) --> (for all x in A)(~P(x)). Or in other words, if I don't like Tron then I don't like any recent movie?

Or you could go for the contrapositive: If I like any recent movies then Tron has to be one of them?

spam gives you points (1)

Seth024 (1241160) | more than 2 years ago | (#39466797)

if you keep spamming i,j,k and l, your score keeps going up.

also, why doesn't it work in firefox??

This again... (4, Funny)

zAPPzAPP (1207370) | more than 2 years ago | (#39466827)

226 byte which I am sure include library calls, only runs on top of the multi megabyte of browser code, may use various other resources as well.

By this standard, I can write Tron in 1 bit.

1

There.
Call it the "Run Tron Bit". It runs on top of a full impletation of Tron.

Re:This again... (3, Interesting)

sco08y (615665) | more than 2 years ago | (#39467145)

226 byte which I am sure include library calls, only runs on top of the multi megabyte of browser code, may use various other resources as well.

By this standard, I can write Tron in 1 bit.

1

There.
Call it the "Run Tron Bit". It runs on top of a full impletation of Tron.

Anything that has a display of some sort has library calls to control that display. If you were writing this on an old C-64, it had a comprehensive sprite library that performed collision detection and perfectly synchronized updates, without you doing more than setting a few registers carefully. If you were playing 6502 machine code golf, you could probably write this in half the bytes. Switching to a graphics mode was (IIRC) a single assignment, clearing the screen was a function provided by the BASIC interpreter, and polling for key events was a simple call. Updating the display, naturally, involved writing to a predesignated area of memory. You could even switch back to text mode to print out GAME OVER when you were done.

In this example, the library calls, which are deliberately designed to be fairly verbose in order to promote readability, chew up much of their byte budget with verbose keywords like onkeyup, getContext, fillRect, etc.

Also, since you're dealing with complex libraries that provide lots features, code has to turn off some of those features. In this case, they actually generate javascript errors and ignore them. They then have to go through handling key events, handling movement and such, and all with some very cleverly compressed techniques. For instance, they grab the mod of the keyvalue and use that as an index to an array of values to update the player's direction.

Re:This again... (2)

Ksevio (865461) | more than 2 years ago | (#39467175)

The challenge was to write the game in standard javascript - and he did that. It wasn't to include the graphics display drivers (not all that interesting a problem these days). It's not like he included a jquery library (or anything really). Just 221 bytes (in the latest version) that you can post into an html file and run on your computer (no need for internet access either!)

Re:This again... (1)

Menkhaf (627996) | more than 2 years ago | (#39467991)

1

Hey, that's no one bit. That's a UTF-16 character, which means it is (or rather, may be) a full 32 bits! Back to the drawing board, young lad.

Re:This again... (2)

zAPPzAPP (1207370) | more than 2 years ago | (#39468067)

That's the source code before I run it through my self made, super optimized compiler.

Re:This again... (1)

Volguus Zildrohar (1618657) | more than 2 years ago | (#39468519)

It runs on top of a full impletation of Tron.

Fucking bloat!

My take... (0)

Anonymous Coward | more than 2 years ago | (#39466893)

What an awesome game for showing how irritatingly laggy simple keyboard inputs can be in even the most modern of web browser environment. This is the "future"?

This is going to make me sound old but (2)

SDrag0n (532175) | more than 2 years ago | (#39466941)

Our old low-bit graphics games used to do something or have some goal...

Even Shorter (3, Interesting)

BrokenCube (896491) | more than 2 years ago | (#39467001)

The current version of the code (on the linked site) is only 221 bytes long - and I've had a quick play with it and it can be reduced further to 219 bytes by swapping out the boolean ANDs "&&" for bitwise ANDs "&" twice.

Re:Even Shorter (2)

alokmenghrajani (2602135) | more than 2 years ago | (#39469451)

your are right, thanks! I'll update the code & give you credits.

Re:Even Shorter (1)

alokmenghrajani (2602135) | more than 2 years ago | (#39469591)

your are right, thanks! I'll update the code & give you credits.

i meant to write you are right. Thanks!

Same thing in x86 asm (4, Informative)

Juippi (416370) | more than 2 years ago | (#39467271)

This was fun, because I got pretty much the same thing down to 56 bytes in x86 assembly some 15 years ago. I remember the best entry in the competition I wrote it for being around 48 bytes or so; I missed at least one trick for setting the graphics segment more efficiently, and also something related to either collision handling or keyboard input, don't remember which.
In any case, this [pastebin.com] is possibly the right version of the code. Should compile with NASM, and is even playable in Dosbox with arrow keys if you turn the emulation speed as low as it can go.

Re:Same thing in x86 asm (0)

Anonymous Coward | more than 2 years ago | (#39467969)

Impressive! That means Assembler is only about 4 times better than JavaScript!

Re:Same thing in x86 asm (1)

PCM2 (4486) | more than 2 years ago | (#39468215)

56 bytes of assembly language source code? I highly doubt it.

Re:Same thing in x86 asm (2)

Mr Z (6791) | more than 2 years ago | (#39468591)

There's only 56 bytes that the computer has to read from somewhere to have a runnable program. In the case of Javascript, since there's no compiled bytecode, you have to download and run from the source. For assembly language, I think it's fair to measure the binary that results from assembling, since it's pretty much a 1:1 translation at that level.

Under DOS, I believe you could actually key the whole program's machine code in with Alt-Keypad sequences using "copy con: foo.com" as long as your program didn't have a ^Z in it. Would you count the source code length then as the number of keystrokes on the keyboard then, or the number of bytes produced? (And if so, are we going to count all the shift keypresses for typing curly braces and parentheses in the Javascript program? Ha.)

Take a look at that 672 byte chess program someone mentioned earlier. You don't hear anyone talking about the size of the source code or even the fact that to create the program image requires a machine with 3K. The resulting program image that the machine has to load (mixture of BASIC and machine code) takes 672 bytes of RAM.

Re:Same thing in x86 asm (1)

alokmenghrajani (2602135) | more than 2 years ago | (#39469521)

Are you referring to hugi (http://www.hugi.scene.org/compo/compoold.htm) ? I believe the x86 size optimization people were doing in the 80s and 90s required a different mindset. You needed to really understand the OS environment & memory layout (e.g. putting DOS in graphics mode using a single byte). When optimizing javascript you focus on the javascript language (e.g. what happens when you do things like undefined xor 1). But overall you can't really compare assembly to javascript. Some things in javascript (e.g. regexp) are almost free, while defining a function requires you to write "function(){}" when it's only 2 instructions in assembly.

And how much supporting code? (4, Insightful)

davidbrit2 (775091) | more than 2 years ago | (#39467355)

How many megabytes of supporting code are necessary to run those 226 bytes?

Re:And how much supporting code? (1)

smoothnorman (1670542) | more than 2 years ago | (#39467597)

Yes, this is exactly my point too. As an limiting argument, let's say my window manager had some-sort of graphics interface with more bells and whistles than emacs. "ooo look! i wrote a script that resulted in a full Donkeykong game in less than 32 characters!!" of course, that was one of the features of the fancy fictitious graphics interface that there are a number of example games that could be started with the equivalent of "run('donkkong')"

Re:And how much supporting code? (1)

Ambitwistor (1041236) | more than 2 years ago | (#39467751)

Yeah, seriously. In Python it would be just 11 bytes, 'import tron'.

Re:And how much supporting code? (1)

toriver (11308) | more than 2 years ago | (#39467759)

If you cook a meal, do you say that you and the store clerk and the transport driver and the farmer and the butcher and the miller and the service technician at the electricity company cooked the meal?

Re:And how much supporting code? (1)

davidbrit2 (775091) | more than 2 years ago | (#39468191)

I don't expect them to engineer and construct the computer system from scratch, but claiming it's 226 bytes and ignoring the mountains of libraries and APIs being relied upon throughout the OS and web browser is a bit like ordering from McDonald's and saying you "made dinner".

I read that as (0)

Anonymous Coward | more than 2 years ago | (#39467625)

Javascript Game of Thrones in 226 bytes. Impressive.

Re:I read that as (1)

game kid (805301) | more than 2 years ago | (#39467785)

Given the size of that book, I'm pretty sure a Javascript Game of Thrones would need like 226 disk partitions.

Not particularly impressed by these (1)

Anonymous Coward | more than 2 years ago | (#39467777)

1) It's not really the game, something that kind of maybe looks sort of like the game
2) doesn't really even have the right functionality
3) is only a small bit of logic

Tron();

Tron in 7 bytes in javascript.

not tron (5, Funny)

eyenot (102141) | more than 2 years ago | (#39467923)

I think there's a difference between Tron and Suicidal Etch-A-Sketch

Etch-A-Sketch (4, Funny)

tepples (727027) | more than 2 years ago | (#39467959)

Suicidal Etch-A-Sketch

Please leave Governor Romney out of this.

I set the interval to 50... (2)

bartoku (922448) | more than 2 years ago | (#39468133)

Now it is like I am playing in Matrix time and I rock!

Best viewed in... (0)

Anonymous Coward | more than 2 years ago | (#39468151)

I would just like to express how much I hate anything that promotes using one browser over another.
It's like people have forgot the lessons of the past, or are just totally oblivious to them.

Horrifically Invalid Markup (0)

Anonymous Coward | more than 2 years ago | (#39468871)

It is also horrific from an html point of view. No head, no title, no html, no doctype, no quotes around attributes, no closing of body or canvas tags. That is even skipping nicities like xml prolog and doctype headers. This is more like a bunch of crappy text which happens to trick some browsers into thinking they are html and script. The amazing part is not that this emulates a tron-like animation in a small footprint (with poor latency on the controls I should add), but that it renders anything at all without the browser giving up.

Google: Please bring an end to DirectX! (0)

Anonymous Coward | more than 2 years ago | (#39469379)

If more games were created for Google Chrome, or some other type of cross-platform offering, and good games at that, perhaps we could finally be free from the Smeagol of multimedia: DirectX.

You mean "Nibbles" or "Worm"? (1)

nemui-chan (550759) | more than 2 years ago | (#39470391)

I was super excited when I found out someone had done this for tron... Until I realized it was actually the old qbasic nibbles or worm game. This is neat and all, but its not tron. Its not even the tron light cycle game since you play by yourself. Oh well.

Useless to me... (1)

EmagGeek (574360) | more than 2 years ago | (#39470467)

... 226 bytes is cool and all, but is useless to me since it doesn't work on my platform. I would gladly accept it taking, say, even 15,000 bytes if it actually worked. It's not as if I can't afford the RAM.

I've seen this done with 120 characters - one line (1)

Trax3001BBS (2368736) | more than 2 years ago | (#39471025)

I started with a TRS-80 III, cassette drive storage. There was a magazine,
"80 Micro" which held a contest, who could write the best one line program.

There was a trick to get more characters (an extra 10 or so) in one line I forget
now the total length but think around 120 characters (bytes) on one line.

This was done in Basic using Peeks and Pokes to keep them short.

Lot's of entries; most being this Java Tron cycle type, be it Tron, skiing downhill
or racing; just something controllable going forwards until it hits something.

3D multiplayer Tron in 4kb (0)

Anonymous Coward | more than 2 years ago | (#39472715)

I made this with C++ a while ago:
http://www.pouet.net/prod.php?which=33971
Used crinkler to pack it down...

Stupid? (1)

balbord (447248) | more than 2 years ago | (#39473205)

Has all of /. gone stupid?
Sure it's a lame name for the "project", and it's barely playable, and doesn't work in all browsers... but is a freaking awesome piece of code and all I read here is childish whining. Go back to facebook.

What happened to /.?

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?