473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 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
63 15145
In article <11**********************@j44g2000cwa.googlegroups .com>,
ais523 <ai****@bham.ac.ukwrote:
>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
gcc appears to be such an implementation, when -O is used.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Dec 13 '06 #51
"William Hughes" <wp*******@hotmail.comwrote:
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.
Then it's not a valid chess program on a Cray. This may be one of the
few examples of a purpose for which a Cray is less powerful than a
Sinclair ZX-81.

Richard
Dec 13 '06 #52
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote:
>int main(void){for(;;);}
Pah. These wimpy, verbose languages. In Algol, the "same"
program is only 21% of the size, and for good measure is palindromic,
almost symmetric, and almost a word:

DO~OD
><OT>Running this program on a multi-user system is likely to anger
your fellow users.</OT>
Surely, only if it's a *bad* multi-user system? Or does the
idle loop equally annoy the users?

--
Andy Walker, School of MathSci., Univ. of Nott'm, UK.
an*@maths.nott.ac.uk
Dec 13 '06 #53
In article <el**********@oyez.ccc.nottingham.ac.uk>,
Dr A. N. Walker <an*@maths.nott.ac.ukwrote:
>><OT>Running this program on a multi-user system is likely to anger
your fellow users.</OT>
> Surely, only if it's a *bad* multi-user system? Or does the
idle loop equally annoy the users?
[Still off-topic]

Unfortunately, there seem to be some bad multi-user systems around
these days. Running a single CPU-intensive process on our Linux
systems drastically slows down interactive response and network file
access. Perhaps it's related to Linux's Minix heritage...

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Dec 14 '06 #54
ais523 <ai****@bham.ac.ukwrote:
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
So it still fails to output a legal move within the time limit so
still loses on time. Mission accomplished, either way.
Dave.

--
David Richerby Accelerated Swiss Painting (TM): it's
www.chiark.greenend.org.uk/~davidr/ like a Renaissance masterpiece but
it's made in Switzerland and twice
as fast!
Dec 15 '06 #55
Keith Thompson <ks***@mib.orgwrote:
<OT>Running this program on a multi-user system is likely to anger
your fellow users.
#include <sys/select.h>
int main () { select (1,0,0,0,0); }

Is much friendlier and only a little longer.</OT>
Dave.

--
David Richerby Aquatic Cyber-Laser (TM): it's like
www.chiark.greenend.org.uk/~davidr/ an intense beam of light that exists
only in your computer but it lives in
the sea!
Dec 15 '06 #56
David Richerby <da****@chiark.greenend.org.ukwrites:
Keith Thompson <ks***@mib.orgwrote:
><OT>Running this program on a multi-user system is likely to anger
your fellow users.

#include <sys/select.h>
int main () { select (1,0,0,0,0); }

Is much friendlier and only a little longer.
But it's not portable; the <sys/select.hheader and the select()
function are not part of standard C.
</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 15 '06 #57

David Richerby wrote:
ais523 <ai****@bham.ac.ukwrote:
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

So it still fails to output a legal move within the time limit so
still loses on time. Mission accomplished, either way.
Yes, but if you allow anything that "fails to output a legal
move within the time limit" , isn't the empty program
a solution?

- William Hughes

Dec 15 '06 #58
I remember that somebody wrote a demonstration chess program about 25 years
ago on the Sinclair ZX81, which only had a 1K memory. The program could
take the first three moves.
<dc*****@connx.comwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...

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
Jan 6 '07 #59
On 2006-12-12 17:52:21 +0100, h.********@hccnet.nl said:
>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.
Je hebt gelijk. You are right on this, I second that.

Feb 12 '07 #60
Nice to see Harm-Geert active here too :)

Vincent

p.s. smallest chessprogram on planet in C:

#include <stdio.h>
main() {
printf("i resign\n");
return 0;
}

"Hans" <ma*@mac.macwrote in message
news:45********************@news.astraweb.com...
On 2006-12-12 17:52:21 +0100, h.********@hccnet.nl said:
>>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.

Je hebt gelijk. You are right on this, I second that.

Feb 13 '07 #61
In comp.lang.c Vincent Diepeveen <di**@xs4all.nlwrote:
Nice to see Harm-Geert active here too :)
Currently "Here" includes comp.lang.c, and IMHO the discussion has
become sufficiently un-C-like that it would be best to remove
comp.lang.c from the followup list. Thanks. (f'ups set)

--
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.
Feb 13 '07 #62

h.********@hccnet.nl said:
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.
So the worlds smallest/simplest chess program would make a move,
wait until the other side moves, *then* resign.

Feb 14 '07 #63
Guy Macon <http://www.guymacon.com/wrote:
h.********@hccnet.nl said:
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.

So the worlds smallest/simplest chess program would make a move,
wait until the other side moves, *then* resign.
Just as the world's smallest OS would give you a file, trash it, and
then crash. So why is MS Windows so bleedin' large?

Richard
Feb 15 '07 #64

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.