backtop


Print


  (Source: thrig/Flickr)
Code will fit into a 512 byte block of memory -- the size of roughly a 64-entry double precision array

For hardcore chess or coding nerds, the name 1K ZX Chess may ring a bell.  This 1983 chess program was coded for the ZX81 -- an early computer from a company called Sinclair Research.  The code is noteworthy as it's often cited as the world's smallest chess code, taking up just 672 bytes (not kilobytes (!!)) of memory [source code].  There was even crude AI onboard, although it was by no means a master level chess player.

This week a new project called BootChess made headlines [1][2][3] when it claimed to have broken the three decade old record for "smallest chess program".  Written by Olivier Poudade (aka "baudsurfer"), the program uses only 487 bytes of memory.

It's pretty barebones.  There's no graphics -- the entire game is displayed in ASCII (pieces are identified by letter; capital letters are white, lowercase are black) and you have to enter your moves to the text terminal below in the traditional letter/number coded notation.  But supposedly it's a playable game with crude AI.



It's an impressive achievement, certainly, but there's a couple of problems and disclaimers that the initial media coverage didn't mention.  Much like 1K ZX Chess, the code neglects some more complicated special case chess rules (e.g. castling).  But unlike 1K ZX Chess, which otherwise appears to behave legally under the simplified rules of the game, BootChess is a no good cheater at times.

"ham" comments on BootChess's page:

Well... It is clear to me that you put more interest in making a small chess program that in making a good chess program. That's understandable even if the result is a program very easy to beat but... you cannot say that BootChess is a complete chess program because it does not allow to castle (didn't tried promotions, underpromotions, en passant pawn captures, stalemate... but I bet that are not supported, are they?) and, worst, it does not care about avoid to place a King in check. Every chess player knows that it is illegal (the movement CANNOT be made) to place your king on a square controlled by your rival pieces. If you allow it, then this is not chess.

He includes a screenshot of the illegal behavior.

Bootchess cheating

Indeed, this is worth noting as if 1K ZX Chess had further relaxed the rules, it might have been able to shed a couple hundred more bytes to reach the size of BootChess.  Further, by the sound of it the AI in BootChess is less sophisticated than 1K ZX Chess. 1K ZX Chess didn't do a good job of planning ahead late in the game, but it did avoid obviously bad piece tradeoffs.  BootChess, on the other hand, will happily sacrifice its bishops, rooks, etc. to capture pawns late in the game.

(Poudade responded to the criticism and was good humored about it.  He defended the limitations, pointing out the difficulty in implementing the checking rule in such a small code.  He mentions (as we say above) that the 1K ZX Chess code did break at least 3 FIDE chess rules, although he admits his code likely breaks more FIDE rules than the 1K ZX Chess code.  He concludes, more accurately:

So all in all, it is just the smallest chess implementation program since 1982 if not totally implementing every single FIDE rule, like 1K ZX Chess (adding extra queening promotion).

So to summarize, BootChess is pretty cool and its author deserves kudos.  But as to the claim that it's the "smallest chess program" ever, that's misleading because it's an amateurish cheater (only unintentionally as it doesn't know better).  And it's misleading to say it dethroned the old Sinclair game, as it fails to implement some of the basic simplified rules of chess that the 1K ZX Chess code complied by.

Bootchess

In other words, playing with BootChess is kind of like playing with a little brother or sister... they're likely to brag, they're not going to play very well, and they are liable to cheat (unwittingly or otherwise).

(Side Note: As another commenter points, out a slightly better, slightly bigger program is the ~900 byte award-winning Nanochess code by Oscar Toledo, written in C or Java (depending on the version).)

Sources: BootChess [homepage], [YouTube], via Geek, via Gizmodo





"Death Is Very Likely The Single Best Invention Of Life" -- Steve Jobs






Most Popular Articles







botimage
Copyright 2018 DailyTech LLC. - RSS Feed | Advertise | About Us | Ethics | FAQ | Terms, Conditions & Privacy Information | Kristopher Kubicki