Recommend
20 
 Thumb up
 Hide
16 Posts

Chess» Forums » News

Subject: 487 byte chess program breaks 32-year-old record rss

Your Tags: Add tags
Popular Tags: [View All]
Russ Williams
Poland
Wrocław
Dolny Śląsk
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
http://www.pouet.net/prod.php?which=64962

Quote:
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. You can see the program listed in the February 1983 copy of Your Computer Magazine.

The record held by 1K ZX Chess for the past 32 years has just been beaten this week, however, by the demoscene group Red Sector Inc. They have implemented a fully-playable version of chess called BootChess in just 487 bytes.

It’s not much to look at as you’d expect, but it’s an impressive feat of assembly coding nonetheless. It’s equally impressive that it’s a multi-format game, capable of running on Windows, Linux, OS X, and BSD due to the way in which it was implemented.


reported here http://www.geek.com/games/computer-chess-created-in-487-byte...

linked from here (where I found it) http://games-beta.slashdot.org/story/15/01/28/0148234/comput...

Of course the AI player is terrible, and it does not fully implement standard chess rules (e.g. en passant), but still, simple chess with AI opponent in 487 bytes is indeed impressive assembly language coding!
24 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
David Bush
United States
Radiant
Virginia
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
Pawns promote to queens, which is reportedly more than 1K ZX did. I would be willing to let slide the lack of 3-time repetition and no 50 move rule. But there is no underpromotion, no en passant, no castling, and the "TaxiMax" engine doesn't mind moving into check. I do not call this chess.

You say your program plays chess
But it's just chessette.
I've been to France
So let's just dance.
4 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Russ Williams
Poland
Wrocław
Dolny Śląsk
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
twixter wrote:
But there is no underpromotion, no en passant, no castling, and the "TaxiMax" engine doesn't mind moving into check. I do not call this chess.

It's certainly not FIDE chess, I agree, but it's chess in the "chess family" sense, and in that context, it's a FIDE chess variant which is basically pretty close to FIDE chess compared to most chess family members... "Western chess" from a century or several centuries ago was also not FIDE chess, after all. Shogi is Japanese chess. Etc.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Gastel Etswane
Canada
Peterborough
Ontario
flag msg tools
badge
Avatar
mb
twixter wrote:
Pawns promote to queens, which is reportedly more than 1K ZX did. I would be willing to let slide the lack of 3-time repetition and no 50 move rule. But there is no underpromotion, no en passant, no castling, and the "TaxiMax" engine doesn't mind moving into check. I do not call this chess.

You say your program plays chess
But it's just chessette.
I've been to France
So let's just dance.

They're waiting to release the expansion - maximizing their shelf presence.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Russ Williams
Poland
Wrocław
Dolny Śląsk
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
Gastel wrote:
twixter wrote:
Pawns promote to queens, which is reportedly more than 1K ZX did. I would be willing to let slide the lack of 3-time repetition and no 50 move rule. But there is no underpromotion, no en passant, no castling, and the "TaxiMax" engine doesn't mind moving into check. I do not call this chess.

You say your program plays chess
But it's just chessette.
I've been to France
So let's just dance.

They're waiting to release the expansion - maximizing their shelf presence.

The full implementation of FIDE chess will take 1024 bytes.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Matt Crawford
United States
San Francisco
California
flag msg tools
Avatar
mbmbmbmbmb
twixter wrote:
Pawns promote to queens, which is reportedly more than 1K ZX did. I would be willing to let slide the lack of 3-time repetition and no 50 move rule. But there is no underpromotion, no en passant, no castling, and the "TaxiMax" engine doesn't mind moving into check. I do not call this chess.

You say your program plays chess
But it's just chessette.
I've been to France
So let's just dance.


True, but as they say in their read me file, it's not difficult to write a chess program that follows all the rules. It's hard to write one that plays chess in a tiny amount of data. It's a pretty cool thing!

487 bytes is a very small amount. Even my comment (with your quote) is fifty percent longer than their program.
5 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Maarten D. de Jong
Netherlands
Zaandam
flag msg tools
badge
Avatar
The author should mail this off to Bill Gates with the message 640 bytes ought to be enough for anybody attached.
6 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Michael Sommers
United States
Clinton
New Jersey
flag msg tools
It's a DOS program. If you want to run it on any of the other listed platforms, you need 487 bytes plus the size of the emulator.

Here's the code:

http://olivier.poudade.free.fr/src/BootChess.asm
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Russ Williams
Poland
Wrocław
Dolny Śląsk
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
tms2 wrote:
It's a DOS program. If you want to run it on any of the other listed platforms, you need 487 bytes plus the size of the emulator.

Unless I'm missing something, it seems to be platform independent and runnable from the boot sector of a disk.

Quote:

which has code comments at the start:

; BootChess is the smallest computer implementation of chess on any platform
; Chess in a 512-byte x86 boot sector for Windows / Linux / OS X / DOS / BSD

But I make no claim to having read/understood all the source code. I'm happy to be enlightened if I'm missing something.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Michael Sommers
United States
Clinton
New Jersey
flag msg tools
russ wrote:
tms2 wrote:
It's a DOS program. If you want to run it on any of the other listed platforms, you need 487 bytes plus the size of the emulator.

Unless I'm missing something, it seems to be platform independent and runnable from the boot sector of a disk.

Quote:

which has code comments at the start:

; BootChess is the smallest computer implementation of chess on any platform
; Chess in a 512-byte x86 boot sector for Windows / Linux / OS X / DOS / BSD

But I make no claim to having read/understood all the source code. I'm happy to be enlightened if I'm missing something.

37th Rule of Programming: believe the code, not the comments. The code uses two BIOS interrupts and one DOS interrupt (int 20h), and so won't run natively under Windows, Linux, OS X, or BSD, which use entirely different interrupts. Note also the mention in the comments of PC/emu and Bochs, which are DOS emulators for Unixy systems, and the Windows DOS box. I don't know how any of those work, whether they automatically load a version of DOS on startup, but I guess that they do, because otherwise DOS wouldn't be there to handle the int 20h.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Russ Williams
Poland
Wrocław
Dolny Śląsk
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
tms2 wrote:
russ wrote:
tms2 wrote:
It's a DOS program. If you want to run it on any of the other listed platforms, you need 487 bytes plus the size of the emulator.

Unless I'm missing something, it seems to be platform independent and runnable from the boot sector of a disk.

Quote:

which has code comments at the start:

; BootChess is the smallest computer implementation of chess on any platform
; Chess in a 512-byte x86 boot sector for Windows / Linux / OS X / DOS / BSD

But I make no claim to having read/understood all the source code. I'm happy to be enlightened if I'm missing something.

37th Rule of Programming: believe the code, not the comments. The code uses two BIOS interrupts and one DOS interrupt (int 20h), and so won't run natively under Windows, Linux, OS X, or BSD, which use entirely different interrupts. Note also the mention in the comments of PC/emu and Bochs, which are DOS emulators for Unixy systems, and the Windows DOS box. I don't know how any of those work, whether they automatically load a version of DOS on startup, but I guess that they do, because otherwise DOS wouldn't be there to handle the int 20h.


Interesting fun, I haven't looked at this kind of thing in a long time.

Looking into it more, it looks like the 20h interrupt is simply to terminate, right?
int 20h ; dos 1+ - terminate program

https://en.wikipedia.org/wiki/MS-DOS_API
20h Terminate program

So it would seem that this only means that the little program won't exit correctly, but everything before it attempts to terminate should work, shouldn't it?

===

BUT: ...

Looking into it even more, that 20h interrupt is in this context:

xit:if x86 ; if x86 boot context environment
int 19h ; exit through bootstrap to reboot cpu
else ; else if .com 16-bit binary
int 20h ; dos 1+ - terminate program
end if ; end of exit methods (os load or shell)

So it seems like the int 20h is not even going to be called if the program is not run as a DOS program. At the top of the source appears:

x86 equ 1 ; x86=1 PC/emu vs. win32b/(DOS)Box

I.e. it seems to give you the option at assembly time to assemble it to run off your boot sector or to run as a dos com program.

Or am I confused?


1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Michael Sommers
United States
Clinton
New Jersey
flag msg tools
I didn't look into it that deeply; I just saw the int 20h and stopped.

Even so, it is clear that this will not run under Linux, BSD, etc., without an emulator. It may run on a machine with those OSes installed, but only by rebooting the machine and running this program from the boot sector.
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Russ Williams
Poland
Wrocław
Dolny Śląsk
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
tms2 wrote:
I didn't look into it that deeply; I just saw the int 20h and stopped.

Even so, it is clear that this will not run under Linux, BSD, etc., without an emulator. It may run on a machine with those OSes installed, but only by rebooting the machine and running this program from the boot sector.

Right, that seems to be the POINT: that it can be run from the boot sector (during boot, before the OS is even loaded) and thus it is OS-independent. (With the option of using the assembly directive to assemble it as a DOS program.)

(Presumably in reality most people wanting to use it would use a virtual machine instead of literally installing it on the boot sector of their physical hard drive. Or perhaps put it on the boot sector of a removable disk instead of an internal hard disk.)
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Michael Sommers
United States
Clinton
New Jersey
flag msg tools
russ wrote:
tms2 wrote:
I didn't look into it that deeply; I just saw the int 20h and stopped.

Even so, it is clear that this will not run under Linux, BSD, etc., without an emulator. It may run on a machine with those OSes installed, but only by rebooting the machine and running this program from the boot sector.

Right, that seems to be the POINT: that it can be run from the boot sector (during boot, before the OS is even loaded) and thus it is OS-independent. (With the option of using the assembly directive to assemble it as a DOS program.)

But that's not the same as running on multiple platforms, which is the claim.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Russ Williams
Poland
Wrocław
Dolny Śląsk
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
tms2 wrote:
russ wrote:
tms2 wrote:
I didn't look into it that deeply; I just saw the int 20h and stopped.

Even so, it is clear that this will not run under Linux, BSD, etc., without an emulator. It may run on a machine with those OSes installed, but only by rebooting the machine and running this program from the boot sector.

Right, that seems to be the POINT: that it can be run from the boot sector (during boot, before the OS is even loaded) and thus it is OS-independent. (With the option of using the assembly directive to assemble it as a DOS program.)

But that's not the same as running on multiple platforms, which is the claim.

Agreed, it is sort of odd/confusing. I guess they mean it doesn't matter whether your computer runs Linux, BSD, Windows, or whatever: in any case you can run this tiny program on your computer (because it can be run when you boot, before your OS even loads.)

In fairness, it's such an odd concept and people normally talk simply about "what OS will it run on", so a program which runs when your computer boots, before any OS is even loaded, doesn't fit well into the usual descriptive paradigm (e.g. standard format software information tables showing a program name and yes-no columns of which OS it runs on). In one sense it is compatible with every OS (if you use that OS, you can run it), and in another sense it runs on none of them (because you can run it without even loading an OS.) If they said "It's only for Linux" or something, that too would be wrong.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Peter Mumford
United States
Somerville
Massachusetts
flag msg tools
ceci n'est pas une pipe
Avatar
mbmbmbmbmb
twixter wrote:
...there is no underpromotion, no en passant, no castling, and the "TaxiMax" engine doesn't mind moving into check. I do not call this chess.

Its not chess. It maybe slick programming, but that doesn't make it chess.
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Front Page | Welcome | Contact | Privacy Policy | Terms of Service | Advertise | Support BGG | Feeds RSS
Geekdo, BoardGameGeek, the Geekdo logo, and the BoardGameGeek logo are trademarks of BoardGameGeek, LLC.