Slashdot Mirror


Computer Chess Created In 487 Bytes, Breaks 32-Year-Old Record

An anonymous reader writes: The record for smallest computer implementation of chess on any platform was held by 1K ZX Chess, which saw a release back in 1983 for the Sinclair ZX81. It uses just 672 bytes of memory, and includes most chess rules as well as a computer component to play against. The 32-year-old record has been beaten this week by the demoscene group Red Sector Inc. They have implemented a fully-playable version of chess called BootChess in just 487 bytes (readme file including source code).

42 of 204 comments (clear)

  1. Incredible! by DigitAl56K · · Score: 5, Funny

    Next you'll be telling me you can create operating systems in less than 15GB!

    1. Re:Incredible! by Dutch+Gun · · Score: 5, Insightful

      I've noticed that they take a fairly liberal definition of "chess", as they simply discard certain rules, such as en passant pawn capture or castling moves, which are pretty important chess moves. It's a bit hard to argue that this is really "chess" if they just decide to leave out inconvenient rules ("chess lite?"). I probably wouldn't complain about other ommissions such as the 3-repetition rule, but castling?

      Even so, a very cool accomplishment in micro-optimization techniques.

      --
      Irony: Agile development has too much intertia to be abandoned now.
    2. Re:Incredible! by Anonymous Coward · · Score: 2, Informative

      Depends on what you consider an operating system. Alpine Linux uses 130 MB (http://alpinelinux.org/about), including an usable graphical interface (Xfce).

      A really minimal system, like a virtual machine running a site, can be reduced to far less than that. For instance, Mirage OS (http://www.openmirage.org).

      Windows, OSX, and some Linux distros are not designed to be tweaked like that.

    3. Re:Incredible! by Tablizer · · Score: 5, Funny

      Next you'll be telling me you can create operating systems in less than 15GB!

      If you complain, we'll re-write it in Java and make it 30GB

    4. Re:Incredible! by Anonymous Coward · · Score: 5, Interesting

      I've noticed that they take a fairly liberal definition of "chess", as they simply discard certain rules, such as en passant pawn capture or castling moves, which are pretty important chess moves. It's a bit hard to argue that this is really "chess" if they just decide to leave out inconvenient rules ("chess lite?"). I probably wouldn't complain about other ommissions such as the 3-repetition rule, but castling?

      Hmmm ... Read your history of chess - Modern Chess is a variant called "Mad Queen" - there are more variants of chess than there are of Poker, and just because we have become used to an agreed-upon standard does not invalidate other styles ...

    5. Re:Incredible! by Anonymous Coward · · Score: 2, Informative

      Don't forget MenuetOS and its opensource derivative KolibriOS. They fit on a single floppy.

    6. Re:Incredible! by hcs_$reboot · · Score: 4, Informative

      To be fair, the ZX81 had only 1k of RAM. So they had to cut through the chess rules. Nowadays they could of course implement the whole game including all rules. But would that be interesting provided that it couldn't compare to that 1983 program?

      --
      Slashdot, fix the reply notifications... You won't get away with it...
    7. Re:Incredible! by Anonymous Coward · · Score: 5, Insightful

      Modern Chess is not now a variant called Mad Queen. It is a standardized game referred to as Chess and understood world-wide.

      Modern chess may have originated in a game that at one time was referred to as "Mad Queen".

    8. Re:Incredible! by mrbester · · Score: 2

      DOS and GEM on the same floppy, with room to spare.

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    9. Re:Incredible! by Anonymous Coward · · Score: 3, Interesting

      14nm process CPUs

      To process the bloat.

      99% accurate voice recognition phone

      You must speak very slowly, and with a Cupertino-approved accent.

      holographic 3d goggles

      Oh goodie, another piece of VR headgear that will be hyped for 3 years, bought for 2, then die.

      affordable SSD

      I had an affordable SSD in 1992 for my Psion Series 3a.

    10. Re:Incredible! by aled · · Score: 4, Informative

      there was a 4KB Java games contest some years http://en.m.wikipedia.org/wiki...

      one of the winning entries was a chess game. May be interesting to check.

      --

      "I think this line is mostly filler"
    11. Re:Incredible! by aled · · Score: 3, Informative

      here is the link to aichess4k site http://ulf.ofahrt.de/aichess4k...

      "aichess4k implements all chess rules and tops it off
      with an ai that casual players find difficult to beat."

      and a graphical board from the screenshots

      --

      "I think this line is mostly filler"
    12. Re:Incredible! by hairyfeet · · Score: 2

      Wouldn't Atari Video Chess be even smaller? I really can't see the 2600 cart beating the ZX81 in terms of storage.

      --
      ACs don't waste your time replying, your posts are never seen by me.
    13. Re:Incredible! by mrchaotica · · Score: 2, Insightful

      You've got to be kidding. A visual representation of the board is insufficient to distinguish it from Checkers!

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    14. Re:Incredible! by OakDragon · · Score: 3, Funny

      They would have included a disclaimer, but that would have pushed up the byte count.

    15. Re:Incredible! by Minupla · · Score: 4, Informative

      Looking at the comment threads, yes, it appears to be a 'faithful' implementation of the original code's rules, or rather a superset, since it includes the pawn promotion rule and the original did not.

      Min

      --
      On the whole, I find that I prefer Slashdot posts to twitter ones because I don't get limited to 140 chars before
    16. Re:Incredible! by operagost · · Score: 2

      But... but... these kids will never learn the joy of fiddling with jumpers, or rearranging their config.sys!

      --

      Gamingmuseum.com: Give your 3D accelerator a rest.
    17. Re:Incredible! by reanjr · · Score: 2

      I've tried many cheap versions of electronic chess, and most of them have no support for en passant (a couple don't have support for castling either). Not only that, but playing against other players, most people who play chess for recreation don't seem to know about an passant, anyway. So, let's call it's chess 2.0. Streamlined for the modern audience.

    18. Re:Incredible! by obarel · · Score: 2

      I think the point is that you don't win a 100m race by running 90m and then arguing about the exact definition of a metre.

      It's an incredible feat to squeeze any variant of chess into 487 bytes, but if you're going to compare apples to apples and maintain a record, the games should follow the same rules.

    19. Re:Incredible! by gstoddart · · Score: 2

      What? That doesn't sound right ... because I'm pretty sure I've seen a board which comes with both chess and checkers pieces.

      I'm not buying that at all -- they're both 8x8.

      You're just making shit up.

      --
      Lost at C:>. Found at C.
    20. Re: Incredible! by Kazoo+the+Clown · · Score: 2

      Obligatory Dilbert reference:

      wally: "When I started programming, we didn't have any of these sissy "icons" and "windows". All we had were zeros and ones — and sometimes we didn't even have ones. I once wrote a database using only zeros."
      dilbert: "You had zeros? We had to use the letter "O"."

  2. "Fully-playable" by scottbomb · · Score: 3, Interesting

    or "play-worthy" ?

    There's a difference.

  3. Apple Integer BASIC Chess by beaverdownunder · · Score: 4, Interesting

    0 GOSUB 10000
    1 INPUT "DO YOU WANT INSTRUCTIONS (Y OR N)?",A$: IF A$#"Y" AND A$#"N" THEN 1: IF A$="Y" THEN GOSUB 30000
    2 REF=5: CALL -936
    3 INPUT "COMPUTER TO PLAY WHITE(0) OR BLACK(1)",WHO
    4 IST=0
    5 DIM WC(99),BC(99)
    6 DIM V(6),P(26),C(3)
    7 DIM KING(16)
    8 DIM A(70)
    10 DIM M(120),W(120),B(120),I(6)
    11 DIM G(100)
    12 FOR X=1 TO 120:M(X)=0: NEXT X
    14 FOR X=1 TO 99:W(X)=0:B(X)=0: NEXT X
    15 FOR X=2 TO 9:X1=10*X:X2=X1+1:M(X1)=7:M(X2)=7: NEXT X
    16 DIM STR$(10),FILE$(8),RANK$(8)
    17 FILE$(1)="A":FILE$(2)="B":FILE$(3)="C":FILE$(4)="D":FILE$(5)="E":FILE$(6)="F":FILE$(7)="G":FILE$(8)="H"
    18 RANK$="12345678"
    20 FOR K=1 TO 21:K2=K+99:M(K)=7:M(K2)=7: NEXT K
    22 FOR K=32 TO 39:K2=K+50:M(K)=1:M(K2)=-1: NEXT K
    23 M(22)=4:M(23)=2:M(24)=3:M(25)=5:M(26)=6:M(27)=3:M(28)=2:M(29)=4
    25 FOR K=22 TO 29:K2=K+70:M(K2)=-M(K): NEXT K
    30 I(1)=12:I(2)=15:I(3)=10:I(4)=1:I(5)=6:I(6)=6
    35 V(1)=1:V(2)=3:V(3)=3:V(4)=5:V(5)=9:V(6)=10
    40 P(1)=-1:P(2)=1:P(3)=10:P(4)=-10:P(5)=0:P(6)=1:P(7)=-1
    45 P(8)=10:P(9)=-10:P(10)=-9:P(11)=-11:P(12)=9:P(13)=11:P(14)=0
    50 P(15)=8:P(16)=-8:P(17)=12:P(18)=-12:P(19)=19:P(20)=-19
    55 P(21)=21:P(22)=-21:P(23)=0:P(24)=10:P(25)=20:P(26)=0
    60 C(1)=8:C(2)=0:C(3)=3
    80 IF WHO=1 THEN 90
    85 M(25)=6:M(26)=5:M(95)=-6:M(96)=-5
    90 GOSUB 5000
    93 FOR II=1 TO 120:W(II)=0:B(II)=0: NEXT II
    95 IF WHO=1 THEN 100:T2=0: GOTO 1000
    100 REM MAKE MOVE
    101 GOSUB 4000
    105 Z9=0
    110 GOSUB 4200
    115 GOSUB 5000: IF WHO=0 THEN 1000
    116 M9=M9+1: IF M9>REF THEN 120
    117 IF T2>4 THEN 120: IF IST=1 THEN GOTO 120
    118 F2=9-F2:T2=9-T2: GOSUB 4200: GOSUB 5000: GOTO 100
    120 REM FILL CONTROL ARRAYS
    122 N8=0:IST=1
    125 FOR X1=22 TO 99:WC(X1)=0:BC(X1)=0: IF M(X1)=6 THEN BKING=X1: IF M(X1)=-6 THEN WKING=X1: NEXT X1
    130 FOR X=22 TO 99: IF M(X)<1 THEN 170: IF M(X)=7 THEN 170: GOSUB 8000: IF N9=0 THEN 170
    150 FOR X1=1 TO N9:TO=G(X1)-G(X1)/100*100: IF M(TO)>0 THEN 168
    164 N8=N8+1:A(N8)=G(X1)
    168 BC(TO)=BC(TO)+1
    169 NEXT X1
    170 NEXT X
    172 FOR X=22 TO 99: IF M(X)>-1 THEN 180: GOSUB 8000
    173 IF N9=0 THEN 180
    174 FOR X1=1 TO N9:TO=G(X1)-G(X1)/100*100:WC(TO)=WC(TO)+1
    176 NEXT X1
    180 NEXT X
    181 GOTO 3000: REM CASTLE LOGIC
    182 REM FILL KING CONTROL ARRAY
    184 KING(1)=BKING+1:KING(2)=BKING-1:KING(3)=BKING+10:KING(4)=BKING-10
    185 KING(5)=BKING+11:KING(6)=BKING-11:KING(7)=BKING+9:KING(8)=BKING-9
    186 KING(9)=WKING+1:KING(10)=WKING-1:KING(11)=WKING+10:KING(12)=WKING-10
    187 KING(13)=WKING+11:KING(14)=WKING-11:KING(15)=WKING+9:KING(16)=WKING-9
    190 V9=-10000:I9=0: FOR X4=1 TO N8:N4=0:F4=A(X4)/100
    210 T4=A(X4)-F4*100:F5=M(F4):T5=M(T4)
    212 REM FIND MOVES OFPIECE IN PRESENT POSTION.
    214 X=F4: GOSUB 8000
    225 M(T4)=M(F4):M(F4)=0
    235 GOSUB 9000: IF N4<=V9 THEN 255
    245 V9=N4:F9=F4:T9=T4
    255 M(F4)=F5:M(T4)=T5:
    256 Z9=Z9+1: IF Z9>20 THEN Z9=1: TAB 26: VTAB Z9: PRINT F4;" : ";T4;" V= ";N4
    259 NEXT X4
    270 F1=F9:T1=T9:M(T1)=M(F1):M(F1)=0:F6=F1-F1/10*10-1:F7=10-F1/10:T6=T1-T1/10*10-1:T7=10-T1/10
    280 IF WHO=1 AND F1=22 THEN QROOK=1
    281 IF WHO=1 AND F1=29 THEN KROOK=1
    282 IF M(T1)=6 THEN MKING=1
    283 IF WHO=0 AND F1=22 THEN QROOK=1
    284 IF WHO=0 AND F1=29 THEN KROOK=1
    310 PRINT "FROM ";F6;F7

    1. Re:Apple Integer BASIC Chess by Tablizer · · Score: 2

      "illegal moves...may cause...strange things to happen"

      Quantum chess, my favorite! Oh wait, that's the prenup fineprint

    2. Re: Apple Integer BASIC Chess by beav007 · · Score: 3, Funny

      #!/usr/bin/python import chess # I'm Cave Johnson. We're done here.

  4. He was right! by Tablizer · · Score: 4, Funny

    Toldja, 640 bytes otta be enough for anyone. -Gill Bates

  5. Re:"includes most chess rules" by Anonymous Coward · · Score: 5, Funny

    They have altered the rules. Pray they do not alter it further.

  6. Best short programs by Cafe+Alpha · · Score: 3, Interesting

    It would be cool to see which programming languages could have the best short chess programs.

    I'd nominate Haskell, scheme and prolog to try it in.

    1. Re:Best short programs by Anonymous Coward · · Score: 2, Informative

      It would be cool to see which programming languages could have the best short chess programs.

      I'd nominate Haskell, scheme and prolog to try it in.

      The game discussed here is written in x86 asm. The source code is certainly having more bytes than 487b, but the compiled result is just 487b. If you would write it in any of the languages you mentioned, the compiled result would be bigger.

    2. Re:Best short programs by TapeCutter · · Score: 2

      You're missing the point, it's the size of the binary image on disk that is remarkable, not the size of the source text. Short source text can easily be achieved by putting "chess.exe" in a cmd file.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
  7. Missing chess rules by Sigma+7 · · Score: 2

    From the readme:

    -you don't get under-promotion ;
        -you don't get "en passant" pawn capture ;
        -you don't get castling (queen or king side) ;

    Underpromotion may be understandable, maybe en-passant since it doesn't come up that oftean, but castling makes a ton of games unplayable.

    Also, purists consider anything that implements these three rules to be a better record than something that omits three rules.

  8. I want a showdown! by ockegheim · · Score: 3, Interesting

    BootChess vs1K ZX Chess

    Probably a bit like watching snails race, but snail-races can get interesting.

    --
    I’m old enough to remember 16K of memory being described as “whopping”
  9. Re:some rules *nearly* never come up by fisted · · Score: 3, Interesting

    the fifty-move rule which states that the game may end in a draw if you play 50 moves without any pawns moved or any captures made

    FTFY. It doesn't end automagically, a player has to invoke that rule explicitly.

    (or 100 moves in certain special board states).

    I've never heard about that, but the wikipedia article you linked says that this rule was in effect from 1952-1992. It's not anymore

    I'm willing to call this proof of concept as chess even if it doesn't fully implement that.

    We don't need no proof of concept for chess, it's kind of an old thing. The point here is to fit the stuff in <512 bytes, which they say they couldn't do without leaving away en passant, castling, etc. So I don't really see how this is proving any concept.

    That being said, It's pretty impressive to implement what they did in this little amount of storage. It's just not chess. Now get off my lawn.

  10. Re:Buggy and incomplete by TrollstonButterbeans · · Score: 2

    Buggy? Incomplete?

    Perhaps they intend to work in the games industry.

    --
    Priest: "Universe from nothing, no laws of physics, sped up time"+ huge discrepancies. Creationism? No. Big Bang Theory
  11. Its even more impressive... by Viol8 · · Score: 4, Interesting

    ... when you consider the ZX81 chess was written in Z80 assembler whereas this is in x86 asm and although both have variable sized instructions the x86 will on average be larger.

    1. Re:Its even more impressive... by neilo_1701D · · Score: 2

      ... when you consider the ZX81 chess was written in Z80 assembler whereas this is in x86 asm and although both have variable sized instructions the x86 will on average be larger.

      Why do you say that?

      My understanding (and if I'm wrong feel free to correct) is that the Z-80 is a bastard clone of an 8080. So, byte-for-byte there should be no difference between the two (if you keep the x86 in real mode). BIOS calls and the need to implement the boot sector code add some guff to the x86, of course, which makes RSI's achievement that much more impressive.

  12. Re:some rules *nearly* never come up by Aighearach · · Score: 2

    It would be a lot more impressive if they went to 2k and had it actually working. I can understand the motivation to play code golf, but every code golf I've played requires a fully correct answer to earn the right to count the bytes.

  13. Oh do shut up by Viol8 · · Score: 4, Insightful

    Why can't people like you just appreciate the technical accomplishment instead of nit picking.

    Tell you what - why not go away and try and write any type of chess program then get back to us?

    As someone who has written a chess program which even after some code optimisation still came out at ~3000 lines of C, I can tell you this is damn impressive.

  14. Re:Not real chess by Chess_the_cat · · Score: 2

    You're right if by 100+ you mean 100+(600). Castling was introduced in the 1300s. En Passant in the 1400s.

    --
    Support the First Amendment. Read at -1
  15. Re:some rules *nearly* never come up by schneidafunk · · Score: 2

    Actually, it does end automatically. I've seen it happen playing chess online. In an OTB (over-the-board) game, I am convinced a draw would be agreed upon well beforehand unless one player was going for a time win.

    Regardless, your selective quote left out the end: "In the 20th century it was discovered that some positions of certain endgames can only be won in more than fifty moves (without a capture or a pawn move). The rule was changed to include certain exceptions in which one hundred moves were allowed with particular material combinations. However, more and more exceptions were discovered and in 1992 FIDE abolished all such exceptions and reinstated the strict fifty-move rule."

    --
    Some people die at 25 and aren't buried until 75. -Benjamin Franklin
  16. About the same as a chessboard by tepples · · Score: 2

    My source states that a checkerboard has 64 squares, like a chessboard.

  17. Re:The Real Question.... by jdschulteis · · Score: 2

    Well, the real question is if this program was replicating the same rules as the one that was previously accepted and supposedly beat?

    Like the previous record holder, this program implements neither en passant nor castling.

    Unlike the previous record holder, this program implements queening, so it is both smaller and has an additional feature.