한국   대만   중국   일본 
Squeezing a playable chess program into 487 bytes | Ars Technica

Gaming —

Squeezing a playable chess program into 487 bytes

Smallest version of the game breaks a 32-year-old record; its info file is 114x bigger.

The world's smallest game of computer chess, running inside DOSBox.
The world's smallest game of computer chess, running inside DOSBox.

In a day and age when major game releases can clog up 65 gigabytes of hard drive space or more, it's nice to know that classic game design doesn't require nearly so much storage space. Case in point: BootChess , a playable computer version of the classic board game that fits in a single 487-byte file.

This impressive feat of assembly coding comes courtesy of a coder named Baudsurfer, who posted his tiny effort online earlier this week in formats playable on Windows, Linux, OS X, DOS, and BSD. When we say "playable," we mean that in the most technical sense. Special rules like castling and en passant are missing, pawns can only be promoted to queens, and the game doesn't seem to mind if a king is placed into check by a move, for instance.

The built-in AI is also about as awful as you'd expect from such a tiny binary footprint, sacrificing pieces and position with very little rhyme or reason in our tests. The computer opponent always starts with a "hardcoded Spanish white piece opening," according to the annotated source code included in the ZIP file. The AI can't even use a basic Minimax strategy due to size constraints.

These are just nitpicks when you consider the achievement of getting chess into such a tiny file size, though. The basics of piece movement and capture are all there in a 9 x 10 character text display, controlled by typing piece positions in through the keyboard. The included text file explaining how it all works (which is?more than 114 times the game file itself) serves as a crash course in the "sizetro" demoscene , which uses assembly language trickery to get maximum performance from programs of minimal size.

The previous record for tiny chess programs was a 672-byte chess conversion for the old ZX Spectrum, created by programmer David Horne and shared through a two-page spread in a 1983 edition of Your Computer magazine . Some have called that program the greatest ever written for its sheer compact elegance, but 32-year-old records were meant to be broken.

Outside of the world record, though, the tiny chess program scene is surprisingly robust. Toledo Nanonchess 3 writes the game into under 1,300 characters of C code, and there's a 1KB Javascript implementation available for play in a browser , to name just a few examples.

In any case, we've now entered a brave new world at the lower edge of functional chess program size. Just think: now a Blu-ray disc can hold over 110 million copies of BootChess, rather than just under 80 million copies of that chunky old ZX Spectrum chess program. What a time to be alive.

Channel Ars Technica