News for hackers. Stuff that matters.
Re:ChessBoardJS by kristopolous on Friday July 26, 2013 @12:36PM (#6109052)
reminds me of the js1k/2010 #2 winner: http://js1k.com/2010-first/demo/750

This one is playable.

Re:ChessBoardJS by aidos on Friday July 26, 2013 @12:57PM (#6109160)
That's amazing. It just took me to pieces. As is written here [0] "it’s still strangely humbling to get your arse kicked by 1014 bytes"

[0] http://malevolent.com/weblog/archive/2010/09/07/1k-chess-sho...

Re:ChessBoardJS by gamegoblin on Friday July 26, 2013 @03:56PM (#6110195)
I found it extremely novice and beat it in under 20 moves. What is your chess experience?
Re:ChessBoardJS by aidos on Friday July 26, 2013 @06:10PM (#6110890)
Not huge. I know how to play, but I haven't played much. I think I'd be able to beat a 1024 byte Go game though :)
Re:ChessBoardJS by DanBC on Friday July 26, 2013 @06:58PM (#6111032)
I'd be interested to hear your progress against this 1024 byte chess game. It could make an interesting blog post - each game you play, with some analysis of what you do to try to win and whether that works or not. :-)
Re:ChessBoardJS by Kiro on Friday July 26, 2013 @07:30PM (#6111133)
What's your experience?
Re:ChessBoardJS by gamegoblin on Friday July 26, 2013 @07:32PM (#6111139)
I have played competitively for years.
Re:ChessBoardJS by ca98am79 on Friday July 26, 2013 @12:58PM (#6109163)
Here is the complete code:

   for(B=i=y=u=b=i=5-5,x=10,I=[],l=[];B++<304;I[B-1]=B%x?B/x%x<2|B%x<2?7:B/x&4?0:l[i++]="ECDFBDCEAAAAAAAAIIIIIIIIMKLNJLKM@G@TSb~?A6J57IKJT576,+-48HLSUmgukgg OJNMLK  IDHGFE".charCodeAt(y++)-64:7);function X(c,h,e,s){c^=8;for(var o,S,C,A,R,T,G,d=e&&X(c,0)>1e4,n,N=-1e8,O=20,K=78-h<<9;++O<99;)if((o=I[T=O])&&(G=o^c)<7){A=G--&2?8:4;C=o-9?l[61+G]:49;do if(!(R=I[T+=l[C]])&&!!G|A<3||(R+1^c)>9&&G|A>2){if(!(R-2&7))return K;n=G|(c?T>29:T<91)?o:6^c;S=(R&&l[R&7|32]*2-h-G)+(n-o?110:!G&&(A<2)+1);if(e>h||1<e&e==h&&S>2|d){I[T]=n;I[O]=0;S-=X(c,h+1,e,S-N);if(!(h||e-1|B-O|T-b|S<-1e4))return W(),c&&setTimeout("X(8,0,2),X(8,0,1)",75);I[O]=o;I[T]=R}if(S>N||!h&S==N&&Math.random()<.5)if(N=S,e>1)if(h?s-S<0:(B=O,b=T,0))break}while(!R&G>2||(T=O,(G||A>2|(c?O>78:O<41)&!R)&&++C*--A))}return-K+768<N|d&&N}function W(){i="<table>";for(u=18;u<99;document.body.innerHTML=i+=++u%x-9?"<th width=60 height=60 onclick='I[b="+u+"]>8?W():X(0,0,1)'style='font-size:50px'bgcolor=#"+(u-B?u*.9&1||9:"d")+"0f0e0>&#"+(I[u]?9808+l[67+I[u]]:160):u++&&"<tr>")B=b}W()
Re:ChessBoardJS by kayoone on Friday July 26, 2013 @01:24PM (#6109306)
how do they do this ? do they write it in normal JS and optimze the hell out of it in terms of size? Is it some kind of special compiler or all done by hand ?
Re:ChessBoardJS by Nilzor on Friday July 26, 2013 @02:17PM (#6109622)
A combination, I suppose. First optimize the code so that the number of instructions are kept to a minimum and then use a minifier tool to shorten variable names and such. http://compressorrater.thruhere.net/
Re:ChessBoardJS by zem on Friday July 26, 2013 @03:50PM (#6110155)
i love how he named his function arguments (c,h,e,s). nicely artistic touch.
Re:ChessBoardJS by StavrosK on Friday July 26, 2013 @03:12PM (#6109923)
How the hell does the AI work? It can't be included in that 1 kb, surely!
Re:ChessBoardJS by ybaumes on Saturday July 27, 2013 @10:28AM (#6112976)
It seems to me it is not a "real" AI. I began a game, and after complete development on my side (about 5-6 moves), the opponent AI did only developed pawns, which shows off its limits.

I am not a javascript expert. but given the size of the code, I doubt there is a great IA underluying. Actually I've browsed the mignified code in order to find the AI implementation. The only clue I spot was a call to the Random() function. I won't state it for sure, because I wasn't able to understand the whole code. But I highly guessed it is the basis of the AI implementation. :-)

Re:ChessBoardJS by Donito on Sunday July 28, 2013 @04:34AM (#6116054)
Play a full game and you'll be surprised, the AI is actually surprisingly good and gets better as the game progresses, especially given the size of the code.
Re:ChessBoardJS by StavrosK on Saturday July 27, 2013 @10:35AM (#6112997)
Where's the unobfuscated code? I haven't been able to find it...
Re:ChessBoardJS by ybaumes on Saturday July 27, 2013 @11:02AM (#6113109)
I am not sure you will find. It seems to me that the point of this demo is to submit minified javascript code for an online coder competition.
Re:ChessBoardJS by StavrosK on Saturday July 27, 2013 @11:06AM (#6113128)
Ah, hmm, too bad... It would have been interesting.
Re:ChessBoardJS by gamegoblin on Friday July 26, 2013 @03:58PM (#6110217)
One can write a decent negamax AI in < 10 lines of code.
Re:ChessBoardJS by djrconcepts on Friday July 26, 2013 @03:23PM (#6109981)
thanks for sharing. i hope in the next version, castling the king is added.
Re:ChessBoardJS by ca98am79 on Friday July 26, 2013 @12:52PM (#6109134)
yeah that's really awesome. But you can't castle, and a promoted pawn always becomes a queen
Re:ChessBoardJS by aidos on Friday July 26, 2013 @01:01PM (#6109172)
His 2kb version does everything else. http://nanochess.110mb.com/chess4.html
Re:ChessBoardJS by auctiontheory on Friday July 26, 2013 @01:41PM (#6109401)
I beat it! I beat it!
Re:ChessBoardJS by jmulho on Friday July 26, 2013 @06:02PM (#6110853)
The ability to castle is insignificant next to the power of the force.
Re:ChessBoardJS by sneak on Friday July 26, 2013 @12:42PM (#6109085)
Re:ChessBoardJS by cschneid on Friday July 26, 2013 @06:54PM (#6111021)
Please don't bring reddit style here. There's plenty of reddit on reddit. This kind of snark detracts from what makes this site good.
Re:ChessBoardJS by eksith on Friday July 26, 2013 @02:20PM (#6109640)
Ouch ;)

On a less painful note, these types of scripts that do so much with so little are exactly the type of problem that interest me. I don't even care that I was beaten; I just love the fact that something like this exists.

Just goes to show how algorithmic chess can be. And code, no matter how "primitive" will trump neurons when it comes to algorithms.

Re:ChessBoardJS by Kiro on Friday July 26, 2013 @07:32PM (#6111141)
I don't understand.
Re:ChessBoardJS by gamegoblin on Friday July 26, 2013 @07:58PM (#6111224)
In American English, slang for an insult is a "burn".

e.g.

"You got burned" = "You were insulted"

The poster was making a joke that the OP had been insulted because this other JavaScript board is superior or something, hence, he directed him to treatment centers for a "burn".

This is very common on reddit.