I realise I am a little late to this party, but I wanted to inform you that I recently published LeanChess, which compiles to 288 bytes of x86 machine code:
http://leanchess.com
Naturally, it isn't full chess, but I believe it's worth mentioning.
P.S. I am deeply indebted to H.G.Muller for the excellent Micro-Max documentation.
BootChess (minimal chess engine)
Moderators: hgm, Rebel, chrisw
-
- Posts: 176
- Joined: Sun Dec 08, 2019 8:16 pm
- Full name: Dmitry Shechtman
-
- Posts: 4889
- Joined: Thu Mar 09, 2006 6:34 am
- Location: Pen Argyl, Pennsylvania
Re: BootChess (minimal chess engine)
+1 , yes it does!bob wrote: ↑Fri Jan 30, 2015 1:12 amHere is the smallest program that plays legal chess according to FIDE rules:Dann Corbit wrote:Truly astounding.Xann wrote:Hi all,
A friend just let me know about a 487-byte chess "engine". Don't expect FIDE compliance or search for this size! It will move into check for example; consider it a variant.
Release announcement: http://www.pouet.net/prod.php?which=64962
Direct link: http://olivier.poudade.free.fr/arc/BootChess.zip
Fabien.
Your description of your program raises the question,
"How small can a chess engine be made which can correctly process every fide rule, including draw detection, underpromotion, e.p. capture, etc.?"
I guess that it cannot be done in under 1024 bytes.
int main() {
printf("I offer a draw, accept? ");
scanf("%s", answer);
if (!strcmp(answer, "yes"))
exit 0;
printf("I resign\n");
}
-
- Posts: 4889
- Joined: Thu Mar 09, 2006 6:34 am
- Location: Pen Argyl, Pennsylvania
Re: BootChess (minimal chess engine)
..and the smiley meant Bob was just 'joking' ...hgm wrote: ↑Sat Jan 31, 2015 9:26 amThis has been discussed before, but resigning is not 'playing chess'. It is actually exactly the opposite, namely the way to express that you are not prepared to play chess (anymore).bob wrote:Here is the smallest program that plays legal chess according to FIDE rules:
int main() {
printf("I offer a draw, accept? ");
scanf("%s", answer);
if (!strcmp(answer, "yes"))
exit 0;
printf("I resign\n");
}
So the program you give here can only be said to "not play chess, in a FIDE-compliant way". Complying with FIDE rules does not automatically imply you are 'playing chess'. The FIDE rules for example also require you to shake hands before a game. That doesn't mean that shaking hands is playing chess...
-
- Posts: 201
- Joined: Thu Jun 06, 2019 8:05 pm
- Full name: Percival Tiglao
Re: BootChess (minimal chess engine)
Mine is even shorter. Mine will wait out the clock, losing by time-out. The code is as follows:mar wrote: ↑Fri Jan 30, 2015 1:29 am Actually the program could always resign, making it even smaller (17 bytes):
But yours is clearly stronger.Code: Select all
org 100h mov ah, 9 mov dx, msg int 21h retn msg db 'I resign$'
Code: Select all
jmp $
-
- Posts: 176
- Joined: Sun Dec 08, 2019 8:16 pm
- Full name: Dmitry Shechtman
Re: BootChess (minimal chess engine)
OK, let's try a formal definition.
A minimal chess program is:
1. A program that is executable on a general-purpose computing device,
2. Accepts single-man chess moves as input and,
3. Following each input move, produces an output consisting of either:
a. a legal chess move or
b. the board following a legal chess move,
unless the game has ended.
Note that this is a very broad definition. It implies that a program may accept illegal moves (as does LeanChess), may not accept castling, promotions or e.p. captures (ditto), may not produce some moves (e.g. 2-rank advance), or produce moves past endgame.
A minimal chess program is:
1. A program that is executable on a general-purpose computing device,
2. Accepts single-man chess moves as input and,
3. Following each input move, produces an output consisting of either:
a. a legal chess move or
b. the board following a legal chess move,
unless the game has ended.
Note that this is a very broad definition. It implies that a program may accept illegal moves (as does LeanChess), may not accept castling, promotions or e.p. captures (ditto), may not produce some moves (e.g. 2-rank advance), or produce moves past endgame.
-
- Posts: 4889
- Joined: Thu Mar 09, 2006 6:34 am
- Location: Pen Argyl, Pennsylvania
Re: BootChess (minimal chess engine)
Actually I would rather see it - not accept illegal moves, accept castling, promotions to legal pieces and e.p capture and be able produce 2 rank moves , lets make it play chess.leanchess wrote: ↑Wed Dec 11, 2019 5:54 am OK, let's try a formal definition.
A minimal chess program is:
1. A program that is executable on a general-purpose computing device,
2. Accepts single-man chess moves as input and,
3. Following each input move, produces an output consisting of either:
a. a legal chess move or
b. the board following a legal chess move,
unless the game has ended.
Note that this is a very broad definition. It implies that a program may accept illegal moves (as does LeanChess), may not accept castling, promotions or e.p. captures (ditto), may not produce some moves (e.g. 2-rank advance), or produce moves past endgame.
-
- Posts: 176
- Joined: Sun Dec 08, 2019 8:16 pm
- Full name: Dmitry Shechtman
Re: BootChess (minimal chess engine)
I have a working version with 2-rank, promotions and ad-hoc castling implemented, which still fits in a boot sector. Adding en passant is harder.
-
- Posts: 4556
- Joined: Tue Jul 03, 2007 4:30 am
-
- Posts: 176
- Joined: Sun Dec 08, 2019 8:16 pm
- Full name: Dmitry Shechtman
Re: BootChess (minimal chess engine)
To clarify, LeanChess is self-contained, i.e. I/O and AI, all in 288 bytes.
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: BootChess (minimal chess engine)
My first chess program (for the 6800 micro-processor) also accepted illegal moves. The advantage of that was that it would allow you to castle and perform e.p. capture although it did not know those concepts, by entering those as multiple moves: Kef1-Kg1-Rf1 for O-O, or e5xd5-e5-d6 for e5xd6. It would only move itself when you typed 'enter' (stateless protocol! ).