Main
Date: 19 Feb 2009 08:30:07
From:
Subject: Current world's smallest chess program
Hi, I've recently published my personal web site
at http://nanochess.110mb.com/

It contains my four winning entries from the IOCCC,
and three previously-unreleased chess programs:

o Toledo Nanochess, a chess program in C that
occupies only 1274 non-blank characters, still
being smaller, it beats Micromax v1.6.
o Toledo Picochess, a chess program in C that
fits in 1K of source, but cannot play empassant,
castling or promotion to minor pieces.
o Toledo Javascript Chess, same as Toledo Nanochess
but in Javascript, 2258 bytes.

The three are the current world's smallest chess
programs, of course, until someone does it better.

I'm interested in knowing about any other small
chess programs in C or Javascript, particularly if
them are smaller than mine.

Enjoy it!

Regards,
Oscar Toledo G.




 
Date: 20 Feb 2009 17:55:36
From: user923005
Subject: Re: Current world's smallest chess program
On Feb 20, 4:26=A0pm, The unknown warrior <some-secrtet-
pl...@invalid.invalid > wrote:
> biy...@gmail.com wrote:
> > Hi, I've recently published my personal web site
> > athttp://nanochess.110mb.com/
>
> I'd like to look at your program, but am I the only find to find the
> pictures which move over the screen (probably javascript) *really*
> annoying.
>
> =A0From what I can gather, you must be a pretty decent C programmer if yo=
u
> can write a real chess program in 1274 characters, but your web design
> skills leave a lot to be desired. People generally want to get at the
> content that interests them, and not have to fight the browser to hide
> things that are forced upon them.
>
> Perhaps you can post the C source here. I'll compile it on my Sun
> workstation (SPARC based) and on my laptop (running Solaris x86). I'll
> let you know what happens. (I have both gcc and Sun's Studio Compiler
> Suite). But I cant be bothered to fight a web sight that pushes pictures
> down my throat the way your site does.

It plays against itself, in a game only a computer could love.
For instance, here is one of his nesting places:
r1b1k1nr/pp2nppp/2p5/q2PP3/4P3/2N5/PP3KPP/R1BQ1BNR w kq -

#include <stdio.h >
char *l =3D "ustvrtsuqqqqqqqqyyyyyyyy}{


 
Date: 21 Feb 2009 00:26:12
From: The unknown warrior
Subject: Re: Current world's smallest chess program
biyubi@gmail.com wrote:
> Hi, I've recently published my personal web site
> at http://nanochess.110mb.com/

I'd like to look at your program, but am I the only find to find the
pictures which move over the screen (probably javascript) *really*
annoying.

From what I can gather, you must be a pretty decent C programmer if you
can write a real chess program in 1274 characters, but your web design
skills leave a lot to be desired. People generally want to get at the
content that interests them, and not have to fight the browser to hide
things that are forced upon them.

Perhaps you can post the C source here. I'll compile it on my Sun
workstation (SPARC based) and on my laptop (running Solaris x86). I'll
let you know what happens. (I have both gcc and Sun's Studio Compiler
Suite). But I cant be bothered to fight a web sight that pushes pictures
down my throat the way your site does.


 
Date: 20 Feb 2009 14:36:06
From: user923005
Subject: Re: Current world's smallest chess program
On Feb 20, 11:26=A0am, Keith Thompson <ks...@mib.org > wrote:
> Richard Heathfield <r...@see.sig.invalid> writes:
>
> [...]> Good observations, but I intend to weasel them away anyway. We can
> > get away without stdio.h, I think, because puts returns an int,
> > which is what the compiler will assume in the absence of a dec.
>
> laration
>
> In C90, not in C99.
>
> > Furthermore, although the /return status/ of the program is
> > undefined because of the absence of a return value, the behaviour
> > of the program itself is not.
>
> In C99, not in C90 (in C99, falling off the end of main does an
> implicit "return 0;").
>
> [...]
>

Of course, if the code is assumed to be C99 compliant we have this
difficulty:

From WG14/N1256 Committee Draft =97 Septermber 7, 2007 ISO/IEC 9899:TC3,
xii Foreword

"5 This second edition cancels and replaces the first edition, ISO/IEC
9899:1990, as amended and corrected by ISO/IEC 9899/COR1:1994, ISO/IEC
9899/AMD1:1995, and ISO/IEC 9899/COR2:1996. Major changes from the
previous edition include:
[snip]
=97 remove implicit int
[snip]
=97 remove implicit function declaration"



 
Date: 20 Feb 2009 13:58:37
From: user923005
Subject: Re: Current world's smallest chess program
On Feb 20, 1:41=A0pm, jameskuyper <jameskuy...@verizon.net > wrote:
> user923005 wrote:
> > On Feb 20, 3:30 am, James Kuyper <jameskuy...@verizon.net> wrote:
> ...
> > > It would have been more useful to identify at least one of the ways i=
n
> > > which that code is defective.
>
> > > The C standard doesn't talk about legal or illegal code. It talks abo=
ut
> > > "conforming" and "strictly conforming" code, but those categories are
> > > nearly useless: the first because it includes just about anything (th=
e
> > > script for the play "Hamlet", for instance, is conforming C code); th=
e
> > > second because it excludes just about every useful program.
>
> > > The useful terms that the C standard provides for describing problems
> > > with C code are, roughly in order of increasing seriousness:
> > > "implementation-defined behavior", "unspecified behavior", "constrain=
t
> > > violation", =A0"syntax error", and "undefined behavior". Could you us=
e one
> > > of these terms to describe the worst problem you see in that code?
>
> > main(f, w, c, h, e, S, s)
>
> Yes, I see a problem - probably the same one you do - but would it
> cost you so much effort to add some words saying what the problem is?

I guess I thought it was obvious.

> Anybody likely to actually perpetrate such code is unlikely to be
> aware of the fact that it is defective. It may even do what they
> expect it to do on the system where they're using it.
>
> This particular problem is merely a portability issue; there are two
> ways of defining main() that an implementation is required to accept,
> but it is implementation-defined whether or not an implementation
> supports other ways of defining it. This code can only be used on a
> C90 implementation that supports a version of main() that takes 7 int
> arguments. I'm not aware of any such implementation, but if one does
> exist it could be fully conforming.

I would argue that this is not a C program on any system that lacks
the special compiler which accepts 7 int arguments.
Further, I guess that there is no such compiler anywhere in the world
and his program works by accident.
It's not hard to repair, of course (just declare m
(int,int,int,int,int,int,int) and call that from main()).

I do recognize the difficulty of writing a chess program in general,
and a tiny one in particular.
I also appreciate the aesthetics of IOCCC entries.


 
Date: 20 Feb 2009 13:41:48
From: jameskuyper
Subject: Re: Current world's smallest chess program
user923005 wrote:
> On Feb 20, 3:30 am, James Kuyper <jameskuy...@verizon.net> wrote:
...
> > It would have been more useful to identify at least one of the ways in
> > which that code is defective.
> >
> > The C standard doesn't talk about legal or illegal code. It talks about
> > "conforming" and "strictly conforming" code, but those categories are
> > nearly useless: the first because it includes just about anything (the
> > script for the play "Hamlet", for instance, is conforming C code); the
> > second because it excludes just about every useful program.
> >
> > The useful terms that the C standard provides for describing problems
> > with C code are, roughly in order of increasing seriousness:
> > "implementation-defined behavior", "unspecified behavior", "constraint
> > violation", "syntax error", and "undefined behavior". Could you use one
> > of these terms to describe the worst problem you see in that code?
>
> main(f, w, c, h, e, S, s)

Yes, I see a problem - probably the same one you do - but would it
cost you so much effort to add some words saying what the problem is?
Anybody likely to actually perpetrate such code is unlikely to be
aware of the fact that it is defective. It may even do what they
expect it to do on the system where they're using it.

This particular problem is merely a portability issue; there are two
ways of defining main() that an implementation is required to accept,
but it is implementation-defined whether or not an implementation
supports other ways of defining it. This code can only be used on a
C90 implementation that supports a version of main() that takes 7 int
arguments. I'm not aware of any such implementation, but if one does
exist it could be fully conforming.


  
Date: 20 Feb 2009 14:40:49
From: Keith Thompson
Subject: Re: Current world's smallest chess program
jameskuyper <jameskuyper@verizon.net > writes:
> user923005 wrote:
[...]
>> main(f, w, c, h, e, S, s)
>
[...]
>
> This particular problem is merely a portability issue; there are two
> ways of defining main() that an implementation is required to accept,
> but it is implementation-defined whether or not an implementation
> supports other ways of defining it. This code can only be used on a
> C90 implementation that supports a version of main() that takes 7 int
> arguments. I'm not aware of any such implementation, but if one does
> exist it could be fully conforming.

It depends on what you mean by "supports" and/or "accepts". I doubt
that any real-world C compiler actually documents that it accepts a
form of main that takes 7 int arguments, but the compilers I've used
don't actually check. I compiled and ran a small program with the
above declaration for main. It compiled without complaint, and the 7
parameters appeared to contain the values of argc, argc, envp (the
last two reinterpreted as int values) and four ints worth of
unidentified garbage.

--
Keith Thompson (The_Other_Keith) kst@mib.org <http://www.ghoti.net/~kst >
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


 
Date: 20 Feb 2009 11:32:28
From: user923005
Subject: Re: Current world's smallest chess program
On Feb 20, 3:30=A0am, James Kuyper <jameskuy...@verizon.net > wrote:
> user923005 wrote:
>
> ...
>
> > After running your program through the preprocessor, we get this:
> ...
> > It isn't a legal C program, despite the fact that some compilers will
> > compile and execute the code.
>
> It would have been more useful to identify at least one of the ways in
> which that code is defective.
>
> The C standard doesn't talk about legal or illegal code. It talks about
> "conforming" and "strictly conforming" code, but those categories are
> nearly useless: the first because it includes just about anything (the
> script for the play "Hamlet", for instance, is conforming C code); the
> second because it excludes just about every useful program.
>
> The useful terms that the C standard provides for describing problems
> with C code are, roughly in order of increasing seriousness:
> "implementation-defined behavior", "unspecified behavior", "constraint
> violation", =A0"syntax error", and "undefined behavior". Could you use on=
e
> of these terms to describe the worst problem you see in that code?

main(f, w, c, h, e, S, s)


 
Date: 20 Feb 2009 08:34:05
From: Anthony Fremont
Subject: Re: Current world's smallest chess program
biyubi@gmail.com wrote:
> Hi, I've recently published my personal web site
> at http://nanochess.110mb.com/
>
> It contains my four winning entries from the IOCCC,
> and three previously-unreleased chess programs:
>
> o Toledo Nanochess, a chess program in C that
> occupies only 1274 non-blank characters, still
> being smaller, it beats Micromax v1.6.
> o Toledo Picochess, a chess program in C that
> fits in 1K of source, but cannot play empassant,
> castling or promotion to minor pieces.
> o Toledo Javascript Chess, same as Toledo Nanochess
> but in Javascript, 2258 bytes.
>
> The three are the current world's smallest chess
> programs, of course, until someone does it better.
>
> I'm interested in knowing about any other small
> chess programs in C or Javascript, particularly if
> them are smaller than mine.

That's amazing.




 
Date: 20 Feb 2009 14:29:42
From: Antoninus Twink
Subject: Re: Current world's smallest chess program
On 19 Feb 2009 at 16:30, biyubi@gmail.com wrote:
> o Toledo Nanochess, a chess program in C that occupies only 1274
> non-blank characters, still being smaller, it beats Micromax v1.6.

Well, I for one would like to congratulate you on a remarkable
achievement.

Even by the standards of clc, the responses in this thread have been
amazingly churlish. Of course it's no surprise that Heathfield, Sossman
and their ilk couldn't resist jumping in with their saracastic replies,
only ever able to knock other people.

But it is disappointing that even generally sensible people like Dan
Corbet aren't able to see past their fixation with the "correct"
signature of main(), and as a result only see undefined behavior where
any reasonable person would see (and warmly admire) an extraordinarily
ingenious response to a difficult programming challenge.

Sad, very sad.



 
Date: 19 Feb 2009 15:07:26
From: Peter Nilsson
Subject: Re: Current world's smallest chess program
William Hughes <wpihug...@hotmail.com > wrote:
> Eric Sosman <Eric.Sos...@sun.com> wrote:
> > biy...@gmail.com wrote:
> > > I'm interested in knowing about any other small
> > > chess programs in C or Javascript, particularly if
> > > them are smaller than mine.
> >
> > =A0 =A0 =A0 =A0 main(){return puts("(Resigns)"),0;}
> >
> > (Assumes a pre-C99 implementation. =A0;-)
>
> This can only play white, as playing black it has
> no way of knowing if white's first move was legal.
> (you could add a table of the 20 legal first moves,
> or something similar to allow it to play black).
> Thw question of what qualifies as the "world's smallest
> chess program" clearly depends on the definition
> of "chess program".

Indeed. The judging from the code cited elsethread, the
program does not 'play' chess itself, rather it allows
two humans to play chess, restricted to legal moves.
[Although I doubt it handles draw by tripple repitition.]

By that measure, Eric's program is not a Chess program
because it assumes that a game of Chess is simply the
act of White resigning. :-)

There is also issue of 'smallest'. Whilst the OP is
using character count as the measure, I'd use the count
of non white-space tokens after translation phase 3.

--
Peter


  
Date: 20 Feb 2009 01:08:03
From: Bertrand Mollinier Toublet
Subject: Re: Current world's smallest chess program
Peter Nilsson wrote:
> William Hughes <wpihug...@hotmail.com> wrote:
>> Eric Sosman <Eric.Sos...@sun.com> wrote:
>>> biy...@gmail.com wrote:
>>>> I'm interested in knowing about any other small
>>>> chess programs in C or Javascript, particularly if
>>>> them are smaller than mine.
>>> main(){return puts("(Resigns)"),0;}
>>>
>>> (Assumes a pre-C99 implementation. ;-)
>> This can only play white, as playing black it has
>> no way of knowing if white's first move was legal.
>> (you could add a table of the 20 legal first moves,
>> or something similar to allow it to play black).
>> Thw question of what qualifies as the "world's smallest
>> chess program" clearly depends on the definition
>> of "chess program".
>
> Indeed. The judging from the code cited elsethread, the
> program does not 'play' chess itself,

Actually, it does.
--
"Relax, kick back, and have a nice big frosty mug full of STFU."
-Re:Animator/NANAE/9-3-07


 
Date: 19 Feb 2009 22:32:15
From: The unknown warrior
Subject: Re: Current world's smallest chess program
biyubi@gmail.com wrote:
> Hi, I've recently published my personal web site
> at http://nanochess.110mb.com/
>
> It contains my four winning entries from the IOCCC,
> and three previously-unreleased chess programs:
>
> o Toledo Nanochess, a chess program in C that
> occupies only 1274 non-blank characters, still
> being smaller, it beats Micromax v1.6.
> o Toledo Picochess, a chess program in C that
> fits in 1K of source, but cannot play empassant,
> castling or promotion to minor pieces.
> o Toledo Javascript Chess, same as Toledo Nanochess
> but in Javascript, 2258 bytes.
>
> The three are the current world's smallest chess
> programs, of course, until someone does it better.
>
> I'm interested in knowing about any other small
> chess programs in C or Javascript, particularly if
> them are smaller than mine.
>
> Enjoy it!
>
> Regards,
> Oscar Toledo G.

main() {
printf("I resign");
}


  
Date: 20 Feb 2009 00:24:34
From: Richard Heathfield
Subject: Re: Current world's smallest chess program
The unknown warrior said:

> biyubi@gmail.com wrote:
<snip >
>>
>> I'm interested in knowing about any other small
>> chess programs in C or Javascript, particularly if
>> them are smaller than mine.
>>
<snip >
>
> main() {
> printf("I resign");
> }

Your program lacks ambition. Here is a program of equivalent length,
which has three advantages over your program:

1) it doesn't invoke undefined behaviour;
2) it terminates the output correctly with a newline character;
3) it wins every time.

main() {
puts("YOU resign");
}

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php >
"Usenet is a strange place" - dmr 29 July 1999


   
Date: 20 Feb 2009 07:58:23
From: Anthony Fremont
Subject: Re: Current world's smallest chess program
Richard Heathfield wrote:
> The unknown warrior said:
>
>> biyubi@gmail.com wrote:
> <snip>
>>>
>>> I'm interested in knowing about any other small
>>> chess programs in C or Javascript, particularly if
>>> them are smaller than mine.
>>>
> <snip>
>>
>> main() {
>> printf("I resign");
>> }
>
> Your program lacks ambition. Here is a program of equivalent length,
> which has three advantages over your program:
>
> 1) it doesn't invoke undefined behaviour;

I don't know about that, but your example didn't return an int, nor did it
#include <stdio.h >. Shouldn't it?

> 2) it terminates the output correctly with a newline character;

Interesting, I personally find this to be an unwanted "feature" of puts().
When I want a newline, I prefer to specify them.

> 3) it wins every time.

> main() {
> puts("YOU resign");
> }




    
Date: 20 Feb 2009 18:04:14
From: Richard Heathfield
Subject: Re: Current world's smallest chess program
Anthony Fremont said:

> Richard Heathfield wrote:
>> The unknown warrior said:
>>
>>> biyubi@gmail.com wrote:
>> <snip>
>>>>
>>>> I'm interested in knowing about any other small
>>>> chess programs in C or Javascript, particularly if
>>>> them are smaller than mine.
>>>>
>> <snip>
>>>
>>> main() {
>>> printf("I resign");
>>> }
>>
>> Your program lacks ambition. Here is a program of equivalent
>> length, which has three advantages over your program:
>>
>> 1) it doesn't invoke undefined behaviour;
>
> I don't know about that, but your example didn't return an int,
> nor did it
> #include <stdio.h>. Shouldn't it?

Good observations, but I intend to weasel them away anyway. We can
get away without stdio.h, I think, because puts returns an int,
which is what the compiler will assume in the absence of a dec.
Furthermore, although the /return status/ of the program is
undefined because of the absence of a return value, the behaviour
of the program itself is not.

>
>> 2) it terminates the output correctly with a newline character;
>
> Interesting, I personally find this to be an unwanted "feature" of
> puts(). When I want a newline, I prefer to specify them.

That's what fputs is for. :-)

>
>> 3) it wins every time.
>
>> main() {
>> puts("YOU resign");
>> }

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php >
"Usenet is a strange place" - dmr 29 July 1999


     
Date: 20 Feb 2009 11:26:33
From: Keith Thompson
Subject: Re: Current world's smallest chess program
Richard Heathfield <rjh@see.sig.invalid > writes:
[...]
> Good observations, but I intend to weasel them away anyway. We can
> get away without stdio.h, I think, because puts returns an int,
> which is what the compiler will assume in the absence of a dec.
laration

In C90, not in C99.

> Furthermore, although the /return status/ of the program is
> undefined because of the absence of a return value, the behaviour
> of the program itself is not.

In C99, not in C90 (in C99, falling off the end of main does an
implicit "return 0;").

[...]

--
Keith Thompson (The_Other_Keith) kst@mib.org <http://www.ghoti.net/~kst >
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


      
Date: 21 Feb 2009 04:36:44
From: Richard Heathfield
Subject: Re: Current world's smallest chess program
Keith Thompson said:

> Richard Heathfield <rjh@see.sig.invalid> writes:
> [...]
>> Good observations, but I intend to weasel them away anyway. We
>> can get away without stdio.h, I think, because puts returns an
>> int, which is what the compiler will assume in the absence of a
>> dec.
> laration
>
> In C90, not in C99.

It is clear, however, from the original (on which my code was based)
that C90 is being used (main() rather than int main()).

>
>> Furthermore, although the /return status/ of the program is
>> undefined because of the absence of a return value, the behaviour
>> of the program itself is not.
>
> In C99, not in C90 (in C99, falling off the end of main does an
> implicit "return 0;").

Um, wrong. I mean, yes, what you say about C99 is correct - but what
I said about C89 is nevertheless correct. C&V: 2.1.2.2: "If the
main function executes a return that specifies no value, the
termination status returned to the host environment is undefined."

Note: the program's behaviour is /not/ undefined because of "falling
off" main. Only the termination status is undefined, as I pointed
out earlier.

I might as well deal here with Harald's point about puts():

"If the expression that precedes the parenthesized argument list in
a function call consists solely of an identifier, and if no
declaration is visible for this identifier, the identifier is
implicitly declared exactly as if, in the innermost block containing
the function call, the declaration

extern int identifier();

appeared." (C89: 3.3.2.2)

So far so good. Now, under what circumstances does the lack of a
prototype cause problems? Let's look further at 3.3.2.2:

"If the expression that denotes the called function has a type that
does not include a prototype, the integral promotions are performed
on each argument and arguments that have type float are promoted to
double. These are called the default argument promotions. If the
number of arguments does not agree with the number of parameters,
the behavior is undefined. If the function is defined with a type
that does not include a prototype, and the types of the arguments
after promotion are not compatible with those of the parameters
after promotion, the behavior is undefined."

The number of arguments agrees. The type of a string literal is
certainly compatible with const char * (because otherwise you
couldn't, say, send "foo" to strlen()).

So I'm not sure on what grounds Harald bases his complaint.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php >
"Usenet is a strange place" - dmr 29 July 1999


       
Date: 20 Feb 2009 20:43:58
From: Keith Thompson
Subject: Re: Current world's smallest chess program
Richard Heathfield <rjh@see.sig.invalid > writes:
> Keith Thompson said:
>> Richard Heathfield <rjh@see.sig.invalid> writes:
>> [...]
>>> Good observations, but I intend to weasel them away anyway. We
>>> can get away without stdio.h, I think, because puts returns an
>>> int, which is what the compiler will assume in the absence of a
>>> dec.
>> laration
>>
>> In C90, not in C99.
>
> It is clear, however, from the original (on which my code was based)
> that C90 is being used (main() rather than int main()).

Agreed, but I thought it was worth pointing out anyway.

>>> Furthermore, although the /return status/ of the program is
>>> undefined because of the absence of a return value, the behaviour
>>> of the program itself is not.
>>
>> In C99, not in C90 (in C99, falling off the end of main does an
>> implicit "return 0;").
>
> Um, wrong. I mean, yes, what you say about C99 is correct - but what
> I said about C89 is nevertheless correct. C&V: 2.1.2.2: "If the
> main function executes a return that specifies no value, the
> termination status returned to the host environment is undefined."
>
> Note: the program's behaviour is /not/ undefined because of "falling
> off" main. Only the termination status is undefined, as I pointed
> out earlier.

Whoops, I meant to write "In C90, not in C99 ...", the point being
that in C99 the program's behavior and return value are both
well-defined (ignoring other issues). With that correction I think
we're in agreement.

[...]

--
Keith Thompson (The_Other_Keith) kst@mib.org <http://www.ghoti.net/~kst >
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


 
Date: 19 Feb 2009 14:27:20
From: user923005
Subject: Re: Current world's smallest chess program
On Feb 19, 8:30=A0am, biy...@gmail.com wrote:
> Hi, I've recently published my personal web site
> athttp://nanochess.110mb.com/
>
> It contains my four winning entries from the IOCCC,
> and three previously-unreleased chess programs:
>
> =A0 o Toledo Nanochess, a chess program in C that
> =A0 =A0 occupies only 1274 non-blank characters, still
> =A0 =A0 being smaller, it beats Micromax v1.6.
> =A0 o Toledo Picochess, a chess program in C that
> =A0 =A0 fits in 1K of source, but cannot play empassant,
> =A0 =A0 castling or promotion to minor pieces.
> =A0 o Toledo Javascript Chess, same as Toledo Nanochess
> =A0 =A0 but in Javascript, 2258 bytes.
>
> The three are the current world's smallest chess
> programs, of course, until someone does it better.
>
> I'm interested in knowing about any other small
> chess programs in C or Javascript, particularly if
> them are smaller than mine.

After running your program through the preprocessor, we get this:


char *l =3D "ustvrtsuqqqqqqqqyyyyyyyy}{


  
Date: 20 Feb 2009 11:30:04
From: James Kuyper
Subject: Re: Current world's smallest chess program
user923005 wrote:
...
> After running your program through the preprocessor, we get this:
...
> It isn't a legal C program, despite the fact that some compilers will
> compile and execute the code.

It would have been more useful to identify at least one of the ways in
which that code is defective.

The C standard doesn't talk about legal or illegal code. It talks about
"conforming" and "strictly conforming" code, but those categories are
nearly useless: the first because it includes just about anything (the
script for the play "Hamlet", for instance, is conforming C code); the
second because it excludes just about every useful program.

The useful terms that the C standard provides for describing problems
with C code are, roughly in order of increasing seriousness:
"implementation-defined behavior", "unspecified behavior", "constraint
violation", "syntax error", and "undefined behavior". Could you use one
of these terms to describe the worst problem you see in that code?


 
Date: 19 Feb 2009 12:44:02
From: William Hughes
Subject: Re: Current world's smallest chess program
On Feb 19, 2:01 pm, Eric Sosman <Eric.Sos...@sun.com > wrote:
> biy...@gmail.com wrote:
> > Hi, I've recently published my personal web site
> > athttp://nanochess.110mb.com/
>
> > It contains my four winning entries from the IOCCC,
> > and three previously-unreleased chess programs:
>
> > o Toledo Nanochess, a chess program in C that
> > occupies only 1274 non-blank characters, still
> > being smaller, it beats Micromax v1.6.
> > o Toledo Picochess, a chess program in C that
> > fits in 1K of source, but cannot play empassant,
> > castling or promotion to minor pieces.
> > o Toledo Javascript Chess, same as Toledo Nanochess
> > but in Javascript, 2258 bytes.
>
> > The three are the current world's smallest chess
> > programs, of course, until someone does it better.
>
> > I'm interested in knowing about any other small
> > chess programs in C or Javascript, particularly if
> > them are smaller than mine.
>
> main(){return puts("(Resigns)"),0;}
>
> (Assumes a pre-C99 implementation. ;-)

This can only play white, as playing black it has
no way of knowing if white's first move was legal.
(you could add a table of the 20 legal first moves,
or something similar to allow it to play black).
Thw question of what qualifies as the "world's smallest
chess program" clearly depends on the definition
of "chess program".

- William Hughes


 
Date: 19 Feb 2009 14:05:53
From: Gordon Burditt
Subject: Re: Current world's smallest chess program
>Hi, I've recently published my personal web site
>at http://nanochess.110mb.com/
>
>It contains my four winning entries from the IOCCC,
>and three previously-unreleased chess programs:

Are these chess programs compatible with the new USCF chess rules
(look over in misc.legal for Sam Sloan's postings) where "Knight's
lawyer sues Queen" is a legal move but it may take weeks to accomplish
because of problems getting proper process service.

> o Toledo Nanochess, a chess program in C that
> occupies only 1274 non-blank characters, still
> being smaller, it beats Micromax v1.6.
> o Toledo Picochess, a chess program in C that
> fits in 1K of source, but cannot play empassant,
> castling or promotion to minor pieces.
> o Toledo Javascript Chess, same as Toledo Nanochess
> but in Javascript, 2258 bytes.

That you can get them that small is amazing.

>The three are the current world's smallest chess
>programs, of course, until someone does it better.
>
>I'm interested in knowing about any other small
>chess programs in C or Javascript, particularly if
>them are smaller than mine.


 
Date: 19 Feb 2009 14:01:43
From: Eric Sosman
Subject: Re: Current world's smallest chess program
biyubi@gmail.com wrote:
> Hi, I've recently published my personal web site
> at http://nanochess.110mb.com/
>
> It contains my four winning entries from the IOCCC,
> and three previously-unreleased chess programs:
>
> o Toledo Nanochess, a chess program in C that
> occupies only 1274 non-blank characters, still
> being smaller, it beats Micromax v1.6.
> o Toledo Picochess, a chess program in C that
> fits in 1K of source, but cannot play empassant,
> castling or promotion to minor pieces.
> o Toledo Javascript Chess, same as Toledo Nanochess
> but in Javascript, 2258 bytes.
>
> The three are the current world's smallest chess
> programs, of course, until someone does it better.
>
> I'm interested in knowing about any other small
> chess programs in C or Javascript, particularly if
> them are smaller than mine.

main(){return puts("(Resigns)"),0;}

(Assumes a pre-C99 implementation. ;-)

--
Eric.Sosman@sun.com


 
Date: 19 Feb 2009 18:21:58
From: Tony M
Subject: Re: Current world's smallest chess program
On Thu, 19 Feb 2009 08:30:07 -0800 (PST), biyubi@gmail.com wrote:

>Hi, I've recently published my personal web site
>at http://nanochess.110mb.com/
>
>It contains my four winning entries from the IOCCC,
>and three previously-unreleased chess programs:
>
> o Toledo Nanochess, a chess program in C that
> occupies only 1274 non-blank characters, still
> being smaller, it beats Micromax v1.6.
> o Toledo Picochess, a chess program in C that
> fits in 1K of source, but cannot play empassant,
> castling or promotion to minor pieces.
> o Toledo Javascript Chess, same as Toledo Nanochess
> but in Javascript, 2258 bytes.
>
>The three are the current world's smallest chess
>programs, of course, until someone does it better.
>
>I'm interested in knowing about any other small
>chess programs in C or Javascript, particularly if
>them are smaller than mine.
>
>Enjoy it!
>
>Regards,
>Oscar Toledo G.

Gotta love those obfuscated C programs that look more like line noise
than source code, and perform such complex feats with so little code.

I've always wondered if one of the participants in those 1K coding
contests could make a fully capable Winboard engine with a 1 kilobyte
.com file.