BootChess (minimal chess engine)

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: BootChess (minimal chess engine)

Post by leanchess »

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.
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: BootChess (minimal chess engine)

Post by MikeB »

bob wrote: Fri Jan 30, 2015 1:12 am
Dann Corbit wrote:
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.
Truly astounding.

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.
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");
}

:)
+1 , yes it does!
Image
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: BootChess (minimal chess engine)

Post by MikeB »

hgm wrote: Sat Jan 31, 2015 9:26 am
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");
}

:)
This 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).

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...
..and the smiley meant Bob was just 'joking' ...
Image
dragontamer5788
Posts: 201
Joined: Thu Jun 06, 2019 8:05 pm
Full name: Percival Tiglao

Re: BootChess (minimal chess engine)

Post by dragontamer5788 »

mar wrote: Fri Jan 30, 2015 1:29 am Actually the program could always resign, making it even smaller (17 bytes):

Code: Select all

org 100h
mov ah, 9
mov dx, msg
int 21h
retn

msg db 'I resign$'
But yours is clearly stronger.
Mine is even shorter. Mine will wait out the clock, losing by time-out. The code is as follows:

Code: Select all

jmp $
User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: BootChess (minimal chess engine)

Post by leanchess »

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.
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: BootChess (minimal chess engine)

Post by MikeB »

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.
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.
Image
User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: BootChess (minimal chess engine)

Post by leanchess »

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.
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: BootChess (minimal chess engine)

Post by Ovyron »

MikeB wrote: Wed Dec 11, 2019 6:27 am not accept illegal moves
This should be a job for the GUI.
User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: BootChess (minimal chess engine)

Post by leanchess »

Ovyron wrote: Wed Dec 11, 2019 7:56 am
MikeB wrote: Wed Dec 11, 2019 6:27 am not accept illegal moves
This should be a job for the GUI.
To clarify, LeanChess is self-contained, i.e. I/O and AI, all in 288 bytes.
User avatar
hgm
Posts: 27792
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: BootChess (minimal chess engine)

Post by hgm »

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! :wink: ).