Coder shrinks chess game into a 487 byte program

Scorpus

Posts: 2,162   +239
Staff member

coder game chess 487 byte bootchess

In a pretty incredible feat of coding, a programmer named Baudsurfer has managed to squeeze an entire, playable game of chess into a single 487 byte program. Unless your computer's storage drive is filled to the brim, you'll definitely be able to play this compact version of the classic board game.

Although the game is technically playable, it definitely won't be the most challenging implementation of chess. Due to size constraints, the AI is terrible and moves pieces basically at random. Also, some rules of the game are missing: you can't castle or capture pawns en passant, you can move a king into check, and pawns can only be promoted to queens.

coder game chess 487 byte bootchess

The game is played through a very basic 9x10 text window, with all moves being performed through keyboard input. Instructions on how to play the game are provided through a sizable text file, which just so happens to be 114 times larger than the game itself.

And when you're done with the game, know that you can archive 2,993 copies on a mere 3.5-inch floppy disk. Or over one billion copies on a cheap 500 GB hard drive.

According to Ars Technica, the previous record for the smallest chess program was held by a 672 byte version for the ZX Spectrum, coded way back in 1983 by programmer David Horne. Other tiny chess implementations include a 1 kB Javascript version that you can play right now in your web browser, which manages to include castling and en passant capture.

Permalink to story.

 
On console you can get pretty much get anything to a really low hard drive footprint. I would use C and allot of pointers, but it is not that all impressive graphics are just useless. It would be more impressive if he used a graphic user interface. I bet you can get a chess game in too a 2.5 megabyte size.
 
How big was a sector in dos? 512 bytes I think. He's got extra space for improvements :)
 
Graphics aside, the point was to get all functionality in as little space as possible.

I know this may be irrelevant, but which command interpreter was used and how much space does its programming consume? And was the same command interpreter used back in 1983. If new interpreters was used and allowed for shortcuts that didn't exist in 1983, that wouldn't be a very fair comparison now would it.
 
Minor corrections and answers to comments follow :

"[...] into a single 487 byte program 487 bytes program." : the new record is "468" bytes after eliminating displaying rows and columns which are FIDE standards (An idea pushed by Oscar Toledo) : http://olivier.poudade.free.fr/src/BootChess.asm

"the AI is terrible and moves pieces basically at random." : yes the AI is terrible but stating it moves pieces randomly might be exaggerated when reading the paragraph entitled "5.1 -The TaxiMax ai used" in http://lpaste.net/131646

"Also, some rules of the game are missing: you can't castle or capture pawns en passant, you can move a king into check, and pawns can only be promoted to queens." : yes that is exact but these restrictions also apply equivalently to David Horne's original 1K ZX Chess, which incidently was the point of the exercise

"Other tiny chess implementations include a 1 kB Javascript..." : the 1k boasted size is very misleading as javascript is not binary but interpreted language and there are software dependencies (extra megabytes of libraries) such as the ones of operating systems and browser libraries, contrary to Bootchess which doesn't require any installed Operating system

"I know this may be irrelevant, but which command interpreter was used and how much space does its programming consume? And was the same command interpreter used back in 1983. If new interpreters was used and allowed for shortcuts that didn't exist in 1983, that wouldn't be a very fair comparison now would it." : no interpreter was used, it is hardware (PC BIOS) based only.
 
Back