World smallest chess program

B

biyubi

Hi, a year ago I won the 2005 Best Game categoryof the International
Obfuscated C Code Contestwith a chess program.
http://www.ioccc.org/whowon2005.html
http://www.mailcom.com/ioccc/toledo/hint.htmBut this post is because I
have discovered (asurprise for me) that it is also the worldsmallest
chess program written in C language.It has a size of 3004 bytes, or
2261 bytes simplydeleting all the spacing that makes the knightfigure,
cutting down the evaluation function wouldmake it smaller but that
deteriorates the computergameplay.By the way, if someone doesn't play
chess, here isa simple modification to make the computer playversus
itself, change 1<L&e to 1Regards,Óscar Toledo G.http://www.biyubi.com/
 
B

biyubi

Hi, a year ago I won the 2005 Best Game category
of the International Obfuscated C Code Contest
with a chess program.

http://www.ioccc.org/whowon2005.html
http://www.mailcom.com/ioccc/toledo/hint.htm

But this post is because I have discovered (a
surprise for me) that it is also the world
smallest chess program written in C language.

It has a size of 3004 bytes, or 2261 bytes simply
deleting all the spacing that makes the knight
figure, cutting down the evaluation function would
make it smaller but that deteriorates the computer
gameplay.

By the way, if someone doesn't play chess, here is
a simple modification to make the computer play
versus itself, change 1<L&e to 1

Regards,
Óscar Toledo G.
http://www.biyubi.com/
 
J

jacob navia

Hi, a year ago I won the 2005 Best Game category
of the International Obfuscated C Code Contest
with a chess program.

http://www.ioccc.org/whowon2005.html
http://www.mailcom.com/ioccc/toledo/hint.htm

But this post is because I have discovered (a
surprise for me) that it is also the world
smallest chess program written in C language.

It has a size of 3004 bytes, or 2261 bytes simply
deleting all the spacing that makes the knight
figure, cutting down the evaluation function would
make it smaller but that deteriorates the computer
gameplay.

By the way, if someone doesn't play chess, here is
a simple modification to make the computer play
versus itself, change 1<L&e to 1

Regards,
Óscar Toledo G.
http://www.biyubi.com/

And it works!

Incredible!

Mis sinceras felicitaciones. Eso es una obra de arte.

jacob
 
D

dcorbit

Hi, a year ago I won the 2005 Best Game categoryof the International
Obfuscated C Code Contestwith a chess program.
http://www.ioccc.org/whowon2005.html
http://www.mailcom.com/ioccc/toledo/hint.htmBut this post is because I
have discovered (asurprise for me) that it is also the worldsmallest
chess program written in C language.It has a size of 3004 bytes, or
2261 bytes simplydeleting all the spacing that makes the knightfigure,
cutting down the evaluation function wouldmake it smaller but that
deteriorates the computergameplay.By the way, if someone doesn't play
chess, here isa simple modification to make the computer playversus
itself, change 1<L&e to 1Regards,Óscar Toledo G.http://www.biyubi.com/

It's not the smallest C chess program in the world.
http://home.hccnet.nl/h.g.muller/max1.html
 
J

Jack Klein

But where is the setjmp.h???

It's a standard header supplied with every standard C compiler. If
your compiler does not have it available, it is either a very strange
non-conforming compiler, or perhaps it is installed incorrectly.
 
O

Old Wolf

Hi, a year ago I won the 2005 Best Game categoryof the International
Obfuscated C Code Contestwith a chess program.

cutting down the evaluation function would make it smaller but that
deteriorates the computer gameplay.

Well, in the 5-ply mode I won in 8 moves the first game, and it
allows repetition of the same game each time. You might like
to mix it up a bit by randomizing amonst the top few candidate
moves, if they all have similar evaluations.

The game was: 1. e4 Nc6; 2. d4 Nf6; 3. Bd3 d5; 4. e5 Nd7;
5. c3 f6; 6. Qh5+ g6; 7. Qxg6+ hg; 8. Bxg6#
 
B

biyubi

William Hughes ha escrito:
However this version does.

http://home.hccnet.nl/h.g.muller/max-src2.html

and at 2000 bytes is still smaller.

-William Hughes

My program is still the world smallest chess
program, as it does all legal chess moves (the
other program cannot promote to knight, bishop
or rook).

As a bonus it includes messages for the current
score, stalemate and checkmate and a good board
display for the user's benefit.

Is very possible to cut all those "extras" and
leave a bare chess engine, getting it far below
the actual size of 2044 IOCCC characters (characters
minus spaces, and } { ; followed by space).

But I leave that as an exercise for the readers. ;)

About the random generator, is easy to add a
*NIX only srand(getpid()); at the program start.

Regards,
Óscar Toledo G.
http://www.biyubi.com/
 
D

David Richerby

Old Wolf said:
Well, in the 5-ply mode I won in 8 moves the first game, and it
allows repetition of the same game each time.

Something tells me that playing high quality chess wasn't one of the
project's design goals...


Dave.
 
D

dcorbit

William Hughes ha escrito:


My program is still the world smallest chess
program, as it does all legal chess moves (the
other program cannot promote to knight, bishop
or rook).

As a bonus it includes messages for the current
score, stalemate and checkmate and a good board
display for the user's benefit.

Is very possible to cut all those "extras" and
leave a bare chess engine, getting it far below
the actual size of 2044 IOCCC characters (characters
minus spaces, and } { ; followed by space).

But I leave that as an exercise for the readers. ;)

About the random generator, is easy to add a
*NIX only srand(getpid()); at the program start.

Regards,
Óscar Toledo G.
http://www.biyubi.com/

While I will admit that writing a working chess program is impressive
and your program is no exception, his program does recognize
underpromotion, it just does not play it. So the only consequence will
be suboptimal play on those rare occasions where underpromotion is
beneficial. BTW, his chess program will positively destroy yours in a
course of games.

P.S.
This is the world's smallest chess program. It plays legal chess, but
it will not fare very well in contests:
#include <stdio.h>
int main(void)
{puts("I resign.");return 0;}
 
K

Kenneth Sloan

While I will admit that writing a working chess program is impressive
and your program is no exception, his program does recognize
underpromotion, it just does not play it. So the only consequence will
be suboptimal play on those rare occasions where underpromotion is
beneficial. BTW, his chess program will positively destroy yours in a
course of games.

P.S.
This is the world's smallest chess program. It plays legal chess, but
it will not fare very well in contests:
#include <stdio.h>
int main(void)
{puts("I resign.");return 0;}
This program can be made MUCH shorter.
 
K

Keith Thompson

P.S.
This is the world's smallest chess program. It plays legal chess, but
it will not fare very well in contests:
#include <stdio.h>
int main(void)
{puts("I resign.");return 0;}

<OT>
Reminds me of one of the first programs I wrote (not in C). It would
ask you whether you want to go first. If not, its first move was
always pawn to king 4. After your first move, it would randomly print

Checkmate in [N] moves, (I resign)|(You lose).
</OT>
 
C

Christopher Benson-Manica

In said:
#include <stdio.h>
int main(void)
{puts("I resign.");return 0;}

There's a tic-tac-toe variation that I rather prefer:

#include <stdio.h>
int main(void) {
puts("If we both play optimally it's a draw. Good game.");
return 0;
}
 
R

Random832

2006-11-30 said:
There's a tic-tac-toe variation that I rather prefer:

#include <stdio.h>
int main(void) {
puts("If we both play optimally it's a draw. Good game.");
return 0;
}

Surely one could add a lookup table that says how many [minimum number]
moves to a draw if the player places his first mark in a center, side,
or corner.
 
H

h.g.muller

P.S.
This is the world's smallest chess program. It plays legal chess, but
it will not fare very well in contests:
#include <stdio.h>
int main(void)
{puts("I resign.");return 0;}

Let me clarify something here.

This discussion is obviously only meaningfull is there is an
unambiguous definition of the concept 'Chess Program'. Like always,
when exploring a boundary, this is not completely obvious what this
should be.

I always have found the following definition to work satisfactory:

A chess program is a program that, according to unambiguous
input/output rules defined by the programmer, is able to score
significantly (in the statistical sense) better than 50% against an
opponent that plays random legal moves.

This would exclude quirks like the one above. (Which I consider a good
thing.) Also note that the random move generator does not yet qualify
as a chess program. (In topological terms, it is on the edge, but not
in the set itself.) To be a chess program you have to do something
more, but it can be an infinitesimal amount.

According to my definition, it is not a requirement that the program
plays legal moves in every situation. Requiring so, would be tantamount
to requiring that the program contains no bugs. Since in general this
cannot be proven for a language as powerful as C, requiring such a
thing would render the definition useless. Giving off an illegal move
should simply be counted as a resignation. If a program that has a
habit of doing this does not do it so often that it no longer clearly
beats the random mover, it still is a chess program.

According to this definition, both micro-Max and Toledo are chess
programs by a large margin. Micro-Max is smaller. And stronger :D,
despite the fact that (unlike what was stated above) it does neither
do, nor accept minor promotions. If the opponent does a minor promotion
that makes a difference (i.e. the piece is not immediately captured)
the response of micro-Max should be considered a resignation. This has
negligible impact on its performance.

I don't know if micro-Max is actually the world's smallest chess
program, but I am not aware of any program that is smaller.
 
M

max

No idea how small micro-Max is, but back in the 1980s there was a chess
program that fitted within the 1K ZX-81 memory - Z80 machine code, but
making use of the 16K ZX-81 ROM, for IO. Apparently it played legal but bad
chess.
 
D

David Richerby

max said:
No idea how small micro-Max is, but back in the 1980s there was a
chess program that fitted within the 1K ZX-81 memory - Z80 machine
code, but making use of the 16K ZX-81 ROM, for IO. Apparently it
played legal but bad chess.

IIRC, the ZX-81 chess program didn't allow en passant and/or castling
and/or underpromotion, so can't really be called `legal chess'.


Dave.
 
J

james of tucson

max said:
No idea how small micro-Max is, but back in the 1980s there was a chess
program that fitted within the 1K ZX-81 memory - Z80 machine code, but
making use of the 16K ZX-81 ROM, for IO. Apparently it played legal but bad
chess.

Was that a derivative of Sargon? There were versions of Sargon as early
as 1978. Sargon is actually not that difficult to digest. I read the
book in 1980, and actually considered implementing a version.
Everything you needed to know about Z-80 programming could have been
learned from this program. Add to that perhaps the basic approach to
CP/M syscalls and you were golden, in those days.

http://madscientistroom.org/chm/Sargon.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top