By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,408 Members | 1,796 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,408 IT Pros & Developers. It's quick & easy.

World smallest chess program

P: n/a
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/

Nov 22 '06 #1
Share this Question
Share on Google+
63 Replies


P: n/a
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/

Nov 22 '06 #2

P: n/a
bi****@gmail.com wrote:
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
Nov 22 '06 #3

P: n/a
But where is the setjmp.h???

Nov 22 '06 #4

P: n/a

bi****@gmail.com wrote:
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

Nov 23 '06 #5

P: n/a
dc*****@connx.com wrote:
bi****@gmail.com 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

Nov 23 '06 #6

P: n/a
On 22 Nov 2006 16:19:32 -0800, "keith_emerson" <ni*********@gmail.com>
wrote in comp.lang.c:
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.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 23 '06 #7

P: n/a
bi****@gmail.com 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. 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#

Nov 23 '06 #8

P: n/a

Old Wolf wrote:
dc*****@connx.com wrote:
bi****@gmail.com 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

Nov 23 '06 #9

P: n/a


William Hughes ha escrito:
Old Wolf wrote:
dc*****@connx.com wrote:
bi****@gmail.com 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/

Nov 23 '06 #10

P: n/a
Old Wolf <ol*****@inspire.net.nzwrote:
bi****@gmail.com 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

P: n/a
bi****@gmail.com wrote:
William Hughes ha escrito:
Old Wolf wrote:
dc*****@connx.com wrote:
bi****@gmail.com 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.");return 0;}

Nov 25 '06 #12

P: n/a
dc*****@connx.com wrote:
bi****@gmail.com wrote:
>William Hughes ha escrito:
>>Old Wolf wrote:
dc*****@connx.com wrote:
bi****@gmail.com 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.");return 0;}
This program can be made MUCH shorter.

--
Kenneth Sloan Ke***********@gmail.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

P: n/a
dc*****@connx.com 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.");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>

--
Keith Thompson (The_Other_Keith) 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

P: n/a
In comp.lang.c dc*****@connx.com wrote:
#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;
}

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Nov 30 '06 #15

P: n/a
2006-11-30 <ek**********@chessie.cirr.com>,
Christopher Benson-Manica wrote:
In comp.lang.c dc*****@connx.com wrote:
>#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;
}
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: n/a
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.

Dec 11 '06 #17

P: n/a
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.********@hccnet.nlwrote in message
news:11**********************@l12g2000cwl.googlegr oups.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.");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.

Dec 11 '06 #18

P: n/a
max <no**@none.comwrote:
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

P: n/a
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

P: n/a
David Richerby wrote:
max <no**@none.comwrote:
>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'.
The 1978 Sargon I that, I believe, the ZX-81 chess was based on,
supported E-P and castling. You could implement Sargon I in 8K RAM.
It was not *that* bad. You could beat it easily in the opening of
course, and alpha-beta pruning doesn't really work for endgames, but its
tactics are not all that bad. I believe that in 1980, a Sargon-I on a
Z-80 microcomputer had a rating in the 1600's. I suspect it was the
basis for some of the purpose-built chess computers of the day.

Sargon does a pretty good job of pruning loss-lines, provided they are
evaluated as losses early enough. It is a very good example of
Alpha-Beta pruning, and does what I would call a magnificent job of
pushing the limits of a small memory space for evaluating board
positions. I mean, GNUChess does essentially the same thing (I know PVS
is more than just an optimization of Alpha-Beta, but it's still
essentially the same approach to evaluation).

I've seen smarter guys than myself be beaten time and time again by
GNUChess. Also, I suspect that there are problem setups you could feed
to Sargon that would allow its tactics to play quite strongly, even on a
16K machine.

I'm not seriously trying to compare Sargon I to a computer chess program
that can be configured with hundreds of megabytes of opening book,
complete solutions for 5-piece endgames, and that can exploit
multi-gigahertz processors and gigabytes of ram for tactical evaluation.
But I still say that Sargon and its variants might surprise you. Yeah,
you can beat it every time -- but if you refrain from confusing it in
the opening, you may find it quite surprisingly "strong" in midgame
tactics.

I'm no chess champion, by any means (I play in the 1400's), and I only
dabble in game programming, so don't contribute to the conversation by
tearing my analysis to shreds. I'd actually like to read on this topic
from people who have implement a-b on a board game, for instance.
Dec 12 '06 #21

P: n/a

David Richerby wrote:
max <no**@none.comwrote:
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!
Rybka, the strongest chess engine in the world, ignores some
underpromotions (at one point it ignored all of them).
Is it therefore not a chess program?

Similarly, the chess program Junior won the world championship without
performing underpromotions -- even when an underpromotion is the best
move.
Is Junior therefore not a chess program?

Both of these programs are sold commercially and even used by chess
experts to analyze games.

My two line chess program obeys the FIDE rules of chess and is
therefore a complete and working chess program.
It loses every game, but that is beside the point.

Dec 12 '06 #22

P: n/a

dcor...@connx.com wrote:
David Richerby wrote:
max <no**@none.comwrote:
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!

Rybka, the strongest chess engine in the world, ignores some
underpromotions (at one point it ignored all of them).
Is it therefore not a chess program?

Similarly, the chess program Junior won the world championship without
performing underpromotions -- even when an underpromotion is the best
move.
Is Junior therefore not a chess program?

Both of these programs are sold commercially and even used by chess
experts to analyze games.

My two line chess program obeys the FIDE rules of chess and is
therefore a complete and working chess program.
It loses every game, but that is beside the point.
From:
http://www.chessvariants.com/fidelaws.html
We have this:
"Article 10: The Completed Game
10.1
The game is won by the player who has checkmated his opponent's king.
This immediately ends the game.
10.2
The game is won by the player whose opponent declares he resigns. This
immediately ends the game.
...."
>From article 10.2, it is very clear that:
#include <stdio.h>
int main(void){puts("I resign");return 0}
is a legal chess program. It also works fine for thematic tournaments.

Dec 12 '06 #23

P: n/a

dc*****@connx.com wrote:

>10.2
The game is won by the player whose opponent declares he resigns. This
immediately ends the game.
..."
>>From article 10.2, it is very clear that:
#include <stdio.h>
int main(void){puts("I resign");return 0}
is a legal chess program. It also works fine for thematic tournaments.
Legal, but far from small. stdio.h is *huge*.


Dec 12 '06 #24

P: n/a
Guy Macon <http://www.guymacon.com/said:
>
dc*****@connx.com wrote:

>>10.2
The game is won by the player whose opponent declares he resigns. This
immediately ends the game.
..."
>>>From article 10.2, it is very clear that:
#include <stdio.h>
int main(void){puts("I resign");return 0}
is a legal chess program. It also works fine for thematic tournaments.

Legal, but far from small. stdio.h is *huge*.
puts(const char *);main(){puts("I resign");return 0;}

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 12 '06 #25

P: n/a

Richard Heathfield wrote:
>
Guy Macon <http://www.guymacon.com/said:
>dc*****@connx.com wrote:
>>>10.2
The game is won by the player whose opponent declares he resigns. This
immediately ends the game.
..."

From article 10.2, it is very clear that:
#include <stdio.h>
int main(void){puts("I resign");return 0}
is a legal chess program. It also works fine for thematic tournaments.

Legal, but far from small. stdio.h is *huge*.

puts(const char *);main(){puts("I resign");return 0;}
Now *that's* what I call a small chess-playing program! <grin>

And, as an added bonus, it wins against my computer as often
as I do...


Dec 12 '06 #26

P: n/a
dc*****@connx.com wrote:
David Richerby wrote:
max <no**@none.comwrote:
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'.

Rybka, the strongest chess engine in the world, ignores some
underpromotions (at one point it ignored all of them).
Is it therefore not a chess program?
If it allows you to under-promote, but does not choose to do so itself,
that's legal.

Richard
Dec 12 '06 #27

P: n/a
james of tucson wrote:
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?
No it wasn't actually. The 1K zx81 chess program used no look ahead (or
rather just 1-ply). Iit just evaluated a score for each of its
available moves.

Since the screen contents also were stored in that 1k memory, this
program cleverly didn't have any code to draw the board. You had to
reload the program from tape to play another game. It also used that
screen memory directly for its board representation, i.e. it did not
have any other copy of the board contents in memory.

It was fun to completely disassemble it to see how it worked.
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.
I still have that book, full of pencil annotations. I also wanted to
implement it, but as an 11-year-old that was a daunting task that I
never got around to. It taught me a lot though.
--
Jaap's Puzzle Page:
http://www.geocities.com/jaapsch/puzzles/

Dec 12 '06 #28

P: n/a
Richard Bos <rl*@hoekstra-uitgeverij.nlwrote:
dc*****@connx.com wrote:
>David Richerby wrote:
>>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'.

Rybka, the strongest chess engine in the world, ignores some
underpromotions (at one point it ignored all of them).
Is it therefore not a chess program?

If it allows you to under-promote, but does not choose to do so
itself, that's legal.
Exactly. (Sorry for the `me too' but the question was kind of
directed at me.)
Dave.

--
David Richerby Natural Newspaper (TM): it's like a
www.chiark.greenend.org.uk/~davidr/ daily broadsheet but it's completely
natural!
Dec 12 '06 #29

P: n/a
David Richerby <da****@chiark.greenend.org.ukwrote:
max <no**@none.comwrote:
>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'.
I see now that there was more than one commercially available chess
program for the ZX81. At least one of these implemented all legal
moves but it is implied in

http://www.sincuser.f9.co.uk/016/mindgms.htm

that this required 16KB RAM. I infer this because the article then
goes on to say,

``Artic also produces a technically-excellent game which fits into
the 1K ZX-81. It may not play brilliantly but it is fascinating to
watch the computer scan the moves available to it graphically on
the screen. The computer makes moves very quickly, although it
will not allow the usual en passant and castling which are
available on the bigger games. The game loads very quickly and at
GBP2.95 it is worth the money.''

I suspect that this is the program I was thinking of.
Dave.

--
David Richerby Old-Fashioned Mexi-Pants (TM):
www.chiark.greenend.org.uk/~davidr/ it's like a well-tailored pair of
trousers that comes from Mexico but
it's perfect for your grandparents!
Dec 12 '06 #30

P: n/a
Guy Macon wrote:
dc*****@connx.com wrote:
>10.2
The game is won by the player whose opponent declares he resigns.
This immediately ends the game.
..."+
>>From article 10.2, it is very clear that:
#include <stdio.h>
int main(void){puts("I resign");return 0}
is a legal chess program. It also works fine for thematic
tournaments.

Legal, but far from small. stdio.h is *huge*.
But puts is not. The remainder is a linking problem, and OT. :-)

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Dec 12 '06 #31

P: n/a

max schreef:
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.
One should distingush the sizes of the source code, the executable and
the memory size used including data. The 1KB ZX81 program was a real
achievement, since the 1KB had to hold both the program code and the
data. I am not sure if it was written (entirely) in assembler, though,
because I seem to recall that the ZX-81 had a BASIC interpreter in ROM,
so the program could also have been encoded BASIC instructions (which
could do more per byte than Z80 machine instructions).

In those days I had written a 2KB chess program (code + data) for the
6800 micro-processor, called Usurpator I. The micro-Max project was
actually inspired by the question if I could rival such code density in
a high-level language. The source of such assembly programs was much
larger, of course, since a single-byte assembly instruction typically
took 5 characters to write down. On the other hand, micro-Max is very
memory-hungry for data: in just a few characters you can declare an
array of hundreds of megabytes (int A[1<<26];), and this is exactly
what micro-Max does. So in that sense the comparison is not fair.

Dan and I simply disagree about whether resigning should count as
playing Chess. In my opinion playing Chess is what you do *before* you
resign. That the FIDE rules stipulate that you are allowed to stop
playing Chess any time you like during a game (by resigning) does not
convince me that the stopping itself is part of the game. I would
reserve the term Chess program for a program that can play a game of
Chess to the very end without resigning.

Dec 12 '06 #32

P: n/a

David Richerby wrote:
Richard Bos <rl*@hoekstra-uitgeverij.nlwrote:
dc*****@connx.com wrote:
David Richerby wrote:
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'.

Rybka, the strongest chess engine in the world, ignores some
underpromotions (at one point it ignored all of them).
Is it therefore not a chess program?
If it allows you to under-promote, but does not choose to do so
itself, that's legal.

Exactly. (Sorry for the `me too' but the question was kind of
directed at me.)
How is it differnt than a program that resigns (plays fully under the
FIDE rules of chess)?
It also is simply not exercising every possible rule of the game. In
both cases the programs are simply choosing not to perform some of the
alternatives that are available to them.

If you fail to see the full correspondence between these two
situations, then I am at a loss as to how to make it clear.

Another even shorter alternative is:

int main(void) (while(1);return 0;}

This program always loses the game on time.

Dec 12 '06 #33

P: n/a
<h.********@hccnet.nlwrote:
Dan and I simply disagree about whether resigning should count as
playing Chess. In my opinion playing Chess is what you do *before*
you resign. That the FIDE rules stipulate that you are allowed to
stop playing Chess any time you like during a game (by resigning)
does not convince me that the stopping itself is part of the game. I
would reserve the term Chess program for a program that can play a
game of Chess to the very end without resigning.
In that case,

int main() {while (1);}

is a chess program: it will lose every game on time. I think the best
way to proceed is to use the term `non-trivial chess program'.
Dave.

--
David Richerby Aluminium Bulb (TM): it's like a light
www.chiark.greenend.org.uk/~davidr/ bulb that's really light!
Dec 12 '06 #34

P: n/a
<dc*****@connx.comwrote:
David Richerby wrote:
>Richard Bos <rl*@hoekstra-uitgeverij.nlwrote:
>>dc*****@connx.com wrote:
David Richerby wrote:
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'.

Rybka, the strongest chess engine in the world, ignores some
underpromotions (at one point it ignored all of them).
Is it therefore not a chess program?

If it allows you to under-promote, but does not choose to do so
itself, that's legal.

Exactly. (Sorry for the `me too' but the question was kind of
directed at me.)

How is it differnt than a program that resigns (plays fully under the
FIDE rules of chess)?
It also is simply not exercising every possible rule of the game. In
both cases the programs are simply choosing not to perform some of the
alternatives that are available to them.
As far as I can see, we're in complete agreement! My objection to the
ZX-81 program was that not allow its opponent to castle, capture en
passant or underpromote. If a program wishes to avoid making certain
types of moves itself or to resign without even considering the
position, that's perfectly within its prerogative.

If you fail to see the full correspondence between these two
situations, then I am at a loss as to how to make it clear.

Another even shorter alternative is:

int main(void) (while(1);return 0;}

This program always loses the game on time.
Indeed -- as I posted myself earlier. (This is not a criticism of you
for posting the same program; just an observation that I was already
aware of this idea.)
Dave.

--
David Richerby Pickled Priest (TM): it's like a
www.chiark.greenend.org.uk/~davidr/ man of the cloth but it's preserved
in vinegar!
Dec 12 '06 #35

P: n/a
If you fail to see the full correspondence between these two
situations, then I am at a loss as to how to make it clear.
There is nothing to make clear. We just don't agree on the definition
of Chess.

In my view the rules of Chess are a subset of the FIDE rules. There are
other FIDE rules that prescribe how participants in events organized by
FIDE should behave. These FIDE rules have nothing to do with Chess. The
Dutch Bridge Society has rules for when Bridge players can smoke during
a Bridge game. That dosn't mean that smoking a cigarete is playing
Bridge.

FIDE rules about offering draws, resigning, and other player
interactions that can determine the entry that goes in the score table
of a tournament by negociation without playing, have nothing to do with
Chess. FIDE rules allow you to participate in a FIDE tournament without
playing Chess.

Resigning is *not* a Chess move, it is merely exercising your right to
stop playing Chess. At any turn someone playing a Chess game has the
choice to play (a move) or to resign or forfeit on time (= not play).
Not playing does not violate FIDE rules. But that does not make not
playing playing Chess.

Dec 12 '06 #36

P: n/a
CBFalconer wrote:
Guy Macon wrote:
>dc*****@connx.com wrote:
>>10.2
The game is won by the player whose opponent declares he resigns.
This immediately ends the game.
..."+

From article 10.2, it is very clear that:
#include <stdio.h>
int main(void){puts("I resign");return 0}
is a legal chess program. It also works fine for thematic
tournaments.

Legal, but far from small. stdio.h is *huge*.

But puts is not. The remainder is a linking problem, and OT. :-)
In fact, to elaborate, the following is a satisfactory puts:

int puts(char *s) {
int err;

while (*s && (EOF != (err = putchar(*s++)))) continue;
if (err 0) err = putchar('\n');
return err;
}

For many non-hosted systems, it suffices to code putchar(), which
will usually reduce to a half-dozen lines of assembly at worst.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Dec 12 '06 #37

P: n/a
dc*****@connx.com wrote:
How is it differnt than a program that resigns (plays fully under the
FIDE rules of chess)?
It also is simply not exercising every possible rule of the game.
The difference is, a reasonable person will call you an idiot for making
that program, whereas a program that makes some attempt at actually
playing, might garner some respect.

If you honestly do not see the difference between, say, a one-statement
program that "just resigns", versus say, a one-liner that actually
*plays chess*, 100% completely or otherwise, you have a perception
problem, or you are merely being a clown.
Dec 12 '06 #38

P: n/a
CBFalconer <cb********@yahoo.comwrites:
For many non-hosted systems, it suffices to code putchar(), which
will usually reduce to a half-dozen lines of assembly at worst.
However: the putchar and puts functions are in the hosted
library, which freestanding implementations don't have to support
at all.
--
"Programmers have the right to be ignorant of many details of your code
and still make reasonable changes."
--Kernighan and Plauger, _Software Tools_
Dec 12 '06 #39

P: n/a
dc*****@connx.com writes:
[...]
Another even shorter alternative is:

int main(void) (while(1);return 0;}

This program always loses the game on time.
The "return 0;" is not necessary. In C99, reaching the '}' that
terminates the main function is equivalent to "return 0;". In C90, it
merely causes an unspecified status to be returned to the environment,
but that doesn't matter since it can't ever be executed anyway.

And you can save a single character by using "for" rather than "while":

int main(void){for(;;);}

In C90, you can drop the "int "; it's required in C99.

<OT>Running this program on a multi-user system is likely to anger
your fellow users.</OT>

--
Keith Thompson (The_Other_Keith) 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.
Dec 12 '06 #40

P: n/a
David Richerby <da****@chiark.greenend.org.ukwrites:
<h.********@hccnet.nlwrote:
>Dan and I simply disagree about whether resigning should count as
playing Chess. In my opinion playing Chess is what you do *before*
you resign. That the FIDE rules stipulate that you are allowed to
stop playing Chess any time you like during a game (by resigning)
does not convince me that the stopping itself is part of the game. I
would reserve the term Chess program for a program that can play a
game of Chess to the very end without resigning.

In that case,

int main() {while (1);}

is a chess program: it will lose every game on time. I think the best
way to proceed is to use the term `non-trivial chess program'.
I also suggest considering carefully whether further followups should
go to comp.lang.c, rec.games.chess.computer, or both. If you're not
discussing the C programming language, please consider limiting your
followup to rec.games.chess.computer.

--
Keith Thompson (The_Other_Keith) 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.
Dec 12 '06 #41

P: n/a
h.********@hccnet.nl wrote:
One should distingush the sizes of the source code, the executable and
the memory size used including data. The 1KB ZX81 program was a real
achievement, since the 1KB had to hold both the program code and the
data. I am not sure if it was written (entirely) in assembler, though,
because I seem to recall that the ZX-81 had a BASIC interpreter in ROM,
so the program could also have been encoded BASIC instructions (which
could do more per byte than Z80 machine instructions).
In those days, it was common practice to code in assembler while making
maximum use of routines that could be found in ROM -- you could use it
for constants, use routines as they were meant to be used, and very
clever people figured out ways to use ROM in really bizarre ways, with
arbitrary entry points, setting registers a certain way, etc.
I knew some of this stuff for Model-I TRS-80. I realized it was an
insane practice then, but it was how you pushed the envelope and squoze
every last byte out of the machine.
Dec 12 '06 #42

P: n/a
james of tucson wrote:
dc*****@connx.com wrote:
>How is it differnt than a program that resigns (plays fully under
the FIDE rules of chess)?
It also is simply not exercising every possible rule of the game.

The difference is, a reasonable person will call you an idiot for
making that program, whereas a program that makes some attempt at
actually playing, might garner some respect.

If you honestly do not see the difference between, say, a
one-statement program that "just resigns", versus say, a one-liner
that actually *plays chess*, 100% completely or otherwise, you have
a perception problem, or you are merely being a clown.
Allright. Using the principal of successive refinement:

#include <stdio.h>

int turn;

int main(void)
{
do {
if (!turn++) puts("1: P-K4");
else {
puts("I resign");
return 0;
}
} while (1);
} /* main, fully tested */

Note that it works when playing either white or black. :-) The
next refinement is to get the players move, which will upset the
above universality. Algebraic notation will also upset that.

Ignore any compiler warnings about failure to return a value. The
compiler is confused.

In seriousness, is there an available system for playing postal
chess, which avoids the temptation of letting the program analyze?

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Dec 12 '06 #43

P: n/a
CBFalconer wrote:
[snip]
In seriousness, is there an available system for playing postal
chess, which avoids the temptation of letting the program analyze?
Sure. Those that do not contain analyzing programs like:
http://deepfrozen.tripod.com/index.html
http://www.ectool.nu/
http://jhess.sourceforge.net/
http://astrodogpress.com/chess/
There are some others.

Dec 13 '06 #44

P: n/a
On Tue, 12 Dec 2006 08:37:47 +0000, Guy Macon
<http://www.guymacon.com/wrote:
>
dc*****@connx.com wrote:

>>10.2
The game is won by the player whose opponent declares he resigns. This
immediately ends the game.
..."
>>>From article 10.2, it is very clear that:
#include <stdio.h>
int main(void){puts("I resign");return 0}
is a legal chess program. It also works fine for thematic tournaments.

Legal, but far from small. stdio.h is *huge*.
Perhaps but it's a header file and does not appear in your executable
program.
Remove del for email
Dec 13 '06 #45

P: n/a
CBFalconer said:

<snip>
In seriousness, is there an available system for playing postal
chess, which avoids the temptation of letting the program analyze?
http://www.auspost.com.au
http://www.canadapost.ca
http://www.indiapost.gov.in
http://www.post.japanpost.jp/english/
http://www.newzealandmail.co.nz
http://www.royalmail.com
http://www.usps.com

are the Web sites of just some of the several specialist agencies dedicated
to providing a postal chess service (and other, somewhat related,
services). Alas, they won't normally provide you with an opponent, paper,
pencil, envelopes, pieces, or chess-board. But once you have solved those
problems, they can generally take up the strain from there.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 13 '06 #46

P: n/a
Keith Thompson wrote:
And you can save a single character by using "for" rather than "while":

int main(void){for(;;);}
You can save one more character by using a recursive call to main:

int main(void){main();}

This is likely to break an implementation limit on many
implementations, but I can imagine an implementation that recognizes
the tail-recursion and goes into an infinite loop here (which is the
behaviour the Standard would suggest).
--
ais523

Dec 13 '06 #47

P: n/a

dc*****@connx.com wrote:
>Another even shorter alternative is:

int main(void) (while(1);return 0;}

This program always loses the game on time.
You, sir, are brilliant! You program does indeed play
perfectly legal chess according to both FIDE and USCF
rules, runs on a wide variety of hardware, and is self
documenting as well.

The same program ported to FORTH runs much faster though... :)

Dec 13 '06 #48

P: n/a

Guy Macon wrote:
dc*****@connx.com wrote:
Another even shorter alternative is:

int main(void) (while(1);return 0;}

This program always loses the game on time.

You, sir, are brilliant! You program does indeed play
perfectly legal chess according to both FIDE and USCF
rules, runs on a wide variety of hardware, and is self
documenting as well.

The same program ported to FORTH runs much faster though... :)
On a Cray it executes in 15 seconds.

- William Hughes

Dec 13 '06 #49

P: n/a

David Richerby wrote:
>
<dc*****@connx.comwrote:
>[...] a program that resigns (plays fully under the FIDE rules
of chess) [...] is simply not exercising every possible rule
of the game. In both cases the programs are simply choosing
not to perform some of the alternatives that are available t
to them.

As far as I can see, we're in complete agreement! My objection to the
ZX-81 program was that not allow its opponent to castle, capture en
passant or underpromote. If a program wishes to avoid making certain
types of moves itself or to resign without even considering the
position, that's perfectly within its prerogative.
Exactly so. The ZX-81 was palying something a lot like chess,
but it wasn't playing chess.

Guy Macon
<http://www.guymacon.com/>

Dec 13 '06 #50

63 Replies

This discussion thread is closed

Replies have been disabled for this discussion.