World smallest chess program

Discussion in 'C Programming' started by biyubi@gmail.com, Nov 22, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Guest

    World smallest chess program (corrected)

    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, 2006
    #2
    1. Advertising

  3. jacob navia Guest

    Re: World smallest chess program (corrected)

    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
    jacob navia, Nov 22, 2006
    #3
  4. Re: World smallest chess program (corrected)

    But where is the setjmp.h???
    keith_emerson, Nov 23, 2006
    #4
  5. Guest

    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, 2006
    #5
  6. Old Wolf Guest

    wrote:
    > 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
    Old Wolf, Nov 23, 2006
    #6
  7. Jack Klein Guest

    Re: World smallest chess program (corrected)

    On 22 Nov 2006 16:19:32 -0800, "keith_emerson" <>
    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/~ajo/docs/FAQ-acllc.html
    Jack Klein, Nov 23, 2006
    #7
  8. Old Wolf Guest

    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#
    Old Wolf, Nov 23, 2006
    #8
  9. Old Wolf wrote:
    > wrote:
    > > 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
    William Hughes, Nov 23, 2006
    #9
  10. Guest

    William Hughes ha escrito:

    > Old Wolf wrote:
    > > wrote:
    > > > 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, 2006
    #10
  11. Old Wolf <> wrote:
    > 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!
    David Richerby, Nov 23, 2006
    #11
  12. Guest

    wrote:
    > William Hughes ha escrito:
    >
    > > Old Wolf wrote:
    > > > wrote:
    > > > > 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, 2006
    #12
  13. wrote:
    > wrote:
    >> William Hughes ha escrito:
    >>
    >>> Old Wolf wrote:
    >>>> wrote:
    >>>>> 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
    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/
    Kenneth Sloan, Nov 26, 2006
    #13
  14. 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) <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.
    Keith Thompson, Nov 28, 2006
    #14
  15. In comp.lang.c 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.
    Christopher Benson-Manica, Nov 30, 2006
    #15
  16. Random832 Guest

    2006-11-30 <ekmnrq$dfc$>,
    Christopher Benson-Manica wrote:
    > In comp.lang.c 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.
    Random832, Nov 30, 2006
    #16
  17. Guest

    > 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, 2006
    #17
  18. max Guest

    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.

    <> wrote in message
    news:...
    > > 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.
    >
    max, Dec 11, 2006
    #18
  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.


    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!
    David Richerby, Dec 11, 2006
    #19
  20. 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
    james of tucson, Dec 12, 2006
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Varun Hiremath
    Replies:
    1
    Views:
    469
    Will McGugan
    Sep 18, 2006
  2. CK

    World Smallest Program

    CK, Jul 19, 2005, in forum: C Programming
    Replies:
    23
    Views:
    726
    Richard Bos
    Jul 25, 2005
  3. Replies:
    52
    Views:
    3,447
    karthikbalaguru
    Mar 1, 2009
  4. J. D.
    Replies:
    1
    Views:
    117
    J. D.
    Dec 16, 2004
  5. Larry
    Replies:
    27
    Views:
    424
    Michele Dondi
    Jan 25, 2005
Loading...

Share This Page