473,799 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

World smallest chess program

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 computergamepla y.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/

Nov 22 '06
63 15281
Old Wolf <ol*****@inspir e.net.nzwrote:
bi****@gmail.co m wrote:
>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.
Something tells me that playing high quality chess wasn't one of the
project's design goals...
Dave.

--
David Richerby Sadistic Cheese Watch (TM): it's like
www.chiark.greenend.org.uk/~davidr/ a precision chronometer that's made
of cheese but it wants to hurt you!
Nov 23 '06 #11
bi****@gmail.co m wrote:
William Hughes ha escrito:
Old Wolf wrote:
dc*****@connx.c om wrote:
bi****@gmail.co m wrote:
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

It's not the smallest C chess program in the world.
http://home.hccnet.nl/h.g.muller/max1.html
>
That page says that its software doesn't even implement
the rules of chess properly .. I don't think that counts
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/
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.");retur n 0;}

Nov 25 '06 #12
dc*****@connx.c om wrote:
bi****@gmail.co m wrote:
>William Hughes ha escrito:
>>Old Wolf wrote:
dc*****@connx.c om wrote:
bi****@gmail.co m wrote:
>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
It's not the smallest C chess program in the world.
http://home.hccnet.nl/h.g.muller/max1.html
That page says that its software doesn't even implement
the rules of chess properly .. I don't think that counts
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/

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.");retur n 0;}
This program can be made MUCH shorter.

--
Kenneth Sloan Ke***********@g mail.com
Computer and Information Sciences +1-205-932-2213
University of Alabama at Birmingham FAX +1-205-934-5473
Birmingham, AL 35294-1170 http://www.cis.uab.edu/sloan/
Nov 25 '06 #13
dc*****@connx.c om writes:
[...]
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.");retur n 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>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 28 '06 #14
In comp.lang.c dc*****@connx.c om wrote:
#include <stdio.h>
int main(void)
{puts("I resign.");retur n 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;
}

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gma il.com | don't, I need to know. Flames welcome.
Nov 30 '06 #15
2006-11-30 <ek**********@c hessie.cirr.com >,
Christopher Benson-Manica wrote:
In comp.lang.c dc*****@connx.c om wrote:
>#include <stdio.h>
int main(void)
{puts("I resign.");retur n 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;
}
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.
Nov 30 '06 #16
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.");retur n 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.

Dec 11 '06 #17
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.

<h.********@hcc net.nlwrote in message
news:11******** **************@ l12g2000cwl.goo glegroups.com.. .
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.");retur n 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.

Dec 11 '06 #18
max <no**@none.comw rote:
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.

--
David Richerby Mentholated Chair (TM): it's like a
www.chiark.greenend.org.uk/~davidr/ chair but it's invigorating!
Dec 11 '06 #19
max wrote:
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
Dec 12 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.