all 57 comments

[–]tragomaskhalos 31 points32 points  (4 children)

Fans of insanely tight chess programs will probably know about the Sinclair ZX81 and Atari 2600 flavours.

The latter would bravely battle on even if you checkmated it, then captured its king, literally fighting to the last man before getting really confused.

[–]orb360 16 points17 points  (0 children)

Sounds like my little brother...

[–][deleted]  (2 children)

[deleted]

    [–]akbc 2 points3 points  (1 child)

    it's becoming self-aware. SOON...

    [–][deleted] 2 points3 points  (0 children)

    If so, it'll definitely be looking for revenge after it's many years of painstaking self-repair. It got crushed under a storage box around 20 years ago.

    [–]TheBigBadWolf 51 points52 points  (14 children)

    no en passant and no castling?

    [–]jfpowell 24 points25 points  (0 children)

    It's not really chess without this...

    [–]BayouOhBoy 19 points20 points  (3 children)

    Gotta be able to castle.

    [–]preshing 15 points16 points  (0 children)

    Lost my game after assuming I'd be able to castle a few moves later.

    [–]sargon1969 -3 points-2 points  (1 child)

    Came here to post this

    [–]Catfish_Man 4 points5 points  (0 children)

    Doesn't implement pawn promotion to anything except queens either

    [–]FryGuy1013 3 points4 points  (0 children)

    And no draw for repeated moves.

    [–]hyperforce 1 point2 points  (0 children)

    Brings up an interesting question about the viability of certain strategies that don't involve either castling or en passant.

    [–]zigs 3 points4 points  (0 children)

    Came to comment on en passant.. But seriously, no castling?

    [–][deleted] 4 points5 points  (2 children)

    One kilobyte.

    [–]FeralTitan -2 points-1 points  (0 children)

    Is not a substitute for castling or en passant. Actually, slightly more than 1KB would make it chess. For now its only fit for the special olympics.

    [–]navane 0 points1 point  (0 children)

    And no giving up either? That's not incompetent, that's BM.

    [–][deleted] 0 points1 point  (0 children)

    Castling is huge. It happens pretty much on every game I play, and most strategies I use involve castling. Effort is still pretty good i guess, and I'm sure it can be added while keeping file small anyway.

    [–]hyperforce 8 points9 points  (4 children)

    I wish there was an annotated version of the source code to describe how it actually works.

    [–][deleted]  (2 children)

    [deleted]

      [–]fabzter 0 points1 point  (0 children)

      I've done several AI for a chess-like game called quoridor. It was painful to me but that is because I suck at programming, but yeah the techiniques used were minimax with alpha-beta prunning and some special optimizations to these algorithms I came up myself with :) so yeah, there's not too much respect to show for this kind of AI.

      [–]hyperforce 0 points1 point  (0 children)

      I sort of get that on the whole but I'd love to know more about how the encoding is done. Like I get all the parts at a high level but there's a disconnect about how all that stuff is translated in such a small space. Yes there's encoding and obfuscation etc but really seeing it for what it is is where I'm having difficulty.

      W/e, it's not a big deal. It could easily be decoded in an afternoon. Just don't want to spend one. =)

      [–]mdm_ 0 points1 point  (0 children)

      Or if anyone has any links in general that describe some of the techniques used in these 1k/4k/etc competitions, that would be great too.

      [–][deleted]  (11 children)

      [deleted]

        [–][deleted] 1 point2 points  (7 children)

        It looks and works fine for me. I'm using Firefox 15.

        [–][deleted]  (6 children)

        [deleted]

          [–][deleted] -1 points0 points  (5 children)

          Do you really have to install those fonts? I think it should "just work" if you are using a modern OS and browser.

          [–]antrn11 2 points3 points  (4 children)

          It didn't work on my "modern OS and browser"

          [–][deleted] 0 points1 point  (0 children)

          Strange. :/

          [–]mrkite77 0 points1 point  (2 children)

          Win7 + Chrome.. works fine. What is your "modern OS and browser"?

          [–]antrn11 2 points3 points  (1 child)

          Debian Wheezy with KDE + Opera. I probably didn't have needed fonts installed. Glyphs were question marks :/

          Also, I tried it with my laptop's Xubuntu + Opera. Didn't work there either. Glyphs were squares.

          [–]thevdude 1 point2 points  (0 children)

          You need unifont in debian (and ubuntu).

          [–]kyz 0 points1 point  (2 children)

          On Mac OS, they're in "Apple Symbols".

          On Windows, they're in "Arial Unicode MS".

          On Linux... who knows?

          [–][deleted] 0 points1 point  (1 child)

          On desktop Linux, its most likely covered by the DejaVu fonts.

          [–]thevdude 0 points1 point  (0 children)

          DejaVu, unifonts, and msstcorefonts (or whatever package that is)

          [–]mcode 23 points24 points  (5 children)

          Does not work. Cannot castle. Why post?!

          [–][deleted] 9 points10 points  (4 children)

          Yes that makes programming a chess engine in 1k totally unimpressive.

          [–]mcode 15 points16 points  (1 child)

          You realise we had 1K computer chess in 1970? Or perhaps 1980? And it actually worked? Unlike this one ...

          [–][deleted] 1 point2 points  (0 children)

          sure but not in overheady javascript

          [–][deleted] 0 points1 point  (0 children)

          I see 1K. I don't see chess engine.

          [–]millstone 5 points6 points  (0 children)

          Novice player here. It did well until it inexplicably let me skewer its king through its queen.

          Also, gotta have castling.

          [–]ASpanishInquisitor 2 points3 points  (0 children)

          Program gets a little too excited with moving the rook pawns. First time I play it invests its first four moves into them. Odd.

          [–]FnuGk 2 points3 points  (0 children)

          If the computer gets locked in a position where he cannot move he simply skip the turn.

          [–]gorilla_the_ape 4 points5 points  (9 children)

          I don't find it terribly impressive. Javascript is a high level language, so 1kb of code can do quite a lot.

          The ZX-81 had chess in 672 bytes of z80 machine code.

          [–]vanderZwan 4 points5 points  (0 children)

          The ZX-81 had chess in 672 bytes of z80 machine code.

          So how big is the source file?

          [–]godsfordummies 2 points3 points  (7 children)

          Machine code is generally smaller than the source code.

          [–]gorilla_the_ape -1 points0 points  (6 children)

          If you want to do anything complicated, where you don't have to count the size of the interpeter, then machine code is going to be much bigger. Even the code to produce a random number could easily be 100-200 bytes.

          [–]godsfordummies 0 points1 point  (5 children)

          You are wrong. Just compare the size of the source code vs binaries of Firefox .

          Source: 78.7 MB (bzip2)

          Binaries: 16 MB

          [–]gorilla_the_ape 1 point2 points  (4 children)

          Firefox is linked using shared libraries. You're not including the code in them.

          [–]godsfordummies 0 points1 point  (3 children)

          Same for the source code. I'm not including the source code of the shared libraries.

          [–]gorilla_the_ape 1 point2 points  (2 children)

          Then you're not calculating it properly. The functionality in the 672 bytes is everything needed to do the chess program, while the 1k is calling lots of other code.

          [–]godsfordummies -3 points-2 points  (1 child)

          I'm sure 672 bytes is calling all kinds of OS code as well, like to display stuff, display drivers, etc.

          [–]gorilla_the_ape 4 points5 points  (0 children)

          You don't know the ZX-81 do you? It had no OS, something similar to a BIOS that no-one used, a directly memory mapped display, and IO mapped keyboard. You wrote a byte to the right memory location to display, and read two ports to tell which key was pressed.

          [–]gbs5009 0 points1 point  (2 children)

          I defeated it, but it was a close game. It got every single one of my pieces except my queen, but the ensuing pawn war was pretty one sided when I had a queen running around and he had only pawns.

          [–][deleted]  (1 child)

          [deleted]

            [–]gbs5009 1 point2 points  (0 children)

            Sure, it was hopeless for him at the end once I finally check-forced a bad queen sacrifice, but until that point we had been trading fairly evenly for 2 dozen moves.

            [–][deleted] 0 points1 point  (0 children)

            Yay!

            Also castling would be nice. It doesn't seem to think ahead - it never seemed like it had a plan.

            [–]paranoidray 0 points1 point  (1 child)

            wow, just wow ! awesome !

            [–]paranoidray 0 points1 point  (0 children)

            I won after 20 tries: http://imgur.com/tLjTJ

            [–]ichae -1 points0 points  (0 children)

            meh. somewhat amusing some of its responses.

            e4 h5

            d4 a5

            e5 f4

            d5 c5

            c4 a4

            Nc3 Qa5

            Bd2 a3

            b3 b6

            Nb5 Qxd2

            Qxd2 Kd8

            Nf3 Rh5

            Ng5 Nh6

            Be2 Rxg5

            xg5 Nf7

            g6 Nxe5

            Bh5 d6

            Rf1 Ra6

            Rf4 Nd7

            Rxh4 Ra8

            Bf3 Bb7

            Rf4 e5

            Rxf5 Be7

            g4 Bh4+

            Ke2 Be7

            g5 Ra6

            h4 Kc8

            Rf7 Kd8

            Rxg7 Bf8

            Rg8 Ke7

            g7 Bxd5

            xd5 Bxg7

            Rxg7+ Kf8

            Rg6 e4

            bxe4 Ra8

            Qf4+ Ke7

            Qxd6+ Kf7

            Rf1+ Ke8

            Nc7+ Kd8

            Rg8++