Released Toledo Nanochess with Winboard interface

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
nanochess
Posts: 64
Joined: Thu Feb 19, 2009 4:34 pm
Location: Mexico, Mexico
Contact:

Released Toledo Nanochess with Winboard interface

Post by nanochess » Thu Apr 16, 2009 2:54 pm

Hi everybody, I have uploaded a new version of Toledo Nanochess and it is 40% faster.

Also a version with integrated Winboard interface, the source and the optimized executables are downloadable as a pack. The source code sizes up at slightly less than 2 KB of C language. This is currently the smallest Winboard engine around. :)

zullil
Posts: 5601
Joined: Mon Jan 08, 2007 11:31 pm
Location: PA USA
Full name: Louis Zulli

Re: Released Toledo Nanochess with Winboard interface

Post by zullil » Fri Apr 17, 2009 11:20 pm

Finally, an engine I can beat.

Nice programming by the way, although your code is a bit hard to read. :roll:

Dann Corbit
Posts: 9981
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Released Toledo Nanochess with Winboard interface

Post by Dann Corbit » Sat Apr 18, 2009 9:00 am

I must have bonked something when I was fooling around with the source code because I have never seen any engine play this crazy.

Code: Select all

[Event "Tw00"]
[Site "DCORBIT2008"]
[Date "2009.04.18"]
[Round "1"]
[White "Toledo_nanochess"]
[Black "Toledo_nanochess"]
[Result "0-1"]
[BlackElo "2200"]
[ECO "A27"]
[Opening "English"]
[Time "01:50:03"]
[Variation "Three Knights, 3...f5"]
[WhiteElo "2200"]
[TimeControl "300+5"]
[Termination "normal"]
[PlyCount "40"]
[WhiteType "program"]
[BlackType "program"]

1. c4 {(c2c4) -0.01/6 0} Nc6 {(b8c6) 0.00/6 0} 2. Nc3 {(b1c3) 0.00/6 0} e5
{(e7e5) -0.01/6 1} 3. e4 {(e2e4) +0.02/6 2} Bc5 {(f8c5) +0.11/6 1} 4. d3
{(d2d3) 0.00/6 4} Bxf2+ {(c5f2) +0.79/6 9} 5. Kxf2 {(e1f2) +2.82/6 4} d5
{(d7d5) +0.14/6 10} 6. cxd5 {(c4d5) +1.02/6 1} Nce7 {(c6e7) -0.07/6 16} 7.
d4 {(d3d4) +0.06/6 4} c6 {(c7c6) +0.04/6 6} 8. dxe5 {(d4e5) +0.83/6 2} Qa5
{(d8a5) +0.76/6 15} 9. Be3 {(c1e3) +0.02/6 8} Nh6 {(g8h6) +0.85/6 17} 10.
Qd4 {(d1d4) -0.02/6 19} Ng4+ {(h6g4) +0.87/6 28} 11. Kg3 {(f2g3) -0.12/6
10} Nxe3 {(g4e3) +0.87/6 34} 12. Qxe3 {(d4e3) +2.82/6 6} f5 {(f7f5) +0.93/6
21} 13. Be2 {(f1e2) -0.11/6 7} O-O {(e8g8) +1.09/6 14} 14. Qg5 {(e3g5)
-0.19/6 7} Qc5 {(a5c5) +1.74/6 20} 15. Rd1 {(a1d1) -0.13/6 13} f4+ {(f5f4)
+5.60/6 34} 16. Qxf4 {(g5f4) -3.60/6 3} Rxf4 {(f8f4) +6.55/6 26} 17. Kxf4
{(g3f4) +3.97/6 6} Qf2+ {(c5f2) +5.57/6 15} 18. Nf3 {(g1f3) -0.94/6 2} Ng6+
{(e7g6) +M10/6 13} 19. Kg5 {(f4g5) -M497/6 2} Qxg2+ {(f2g2) +M485/6 17} 20.
Kh5 {(g5h5) -M20/6 5} Qg4# {(g2g4) +M9/6 18} 0-1
[/quote]

Dann Corbit
Posts: 9981
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Released Toledo Nanochess with Winboard interface

Post by Dann Corbit » Sat Apr 18, 2009 9:02 am

zullil wrote:Finally, an engine I can beat.

Nice programming by the way, although your code is a bit hard to read. :roll:
After reformatting a bit it looks like this:

Code: Select all

#include <stdio.h>
#include <time.h>
#include <ctype.h>

char           *l = "ustvrtsuqqqqqqqqyyyyyyyy&#125;&#123;|~z|&#123;&#125;"
"   76Lsabcddcba .pknbrq  PKNBRQ ?A6J57IKJT576,+-48HLSU";
int B, i, y, u, b, I&#91;411&#93;, *G = I, x = 10, z = 15, M = 1e4, D;

int X&#40;int f, int w, int c, int h, int e, int S, int s&#41;
&#123;
    int             t,
                    o,
                    L,
                    E,
                    d,
                    O = f,
                    N = -M * M,
                    K = 78 - h << x,
                    p,
                   *g,
                    n,
                   *m,
                    A,
                    q,
                    r,
                    C,
                    J,
                    a = y ? -x &#58; x;
                    	
    D++;
    y ^= 8;
    d = w || s && X&#40;21, 0, 0, 0, 0, 1, 0&#41; > M;
    G&#91;h + 1&#93; = *G;
    do &#123;;
        if &#40;o = I&#91;p = O&#93;) &#123;
            q = o & z ^ y;
            if &#40;q < 7&#41; &#123;
                A = q-- & 2 ? 8 &#58; 4;
                C = o - 9 & z ? q&#91;"& .$  "&#93; &#58; 42;
                do &#123;
                    r = I&#91;p += C&#91;l&#93; - 64&#93;;
                    if (!w | p == w && q | A > 2 | !r&#41; &#123;
                        g = q | p + a - e ? 0 &#58; I + e;
                        if (!r & &#40;q | A < 3 || g&#41; || &#40;r + 1 & z ^ y&#41; > 9&#41; &#123;
                            m = 0;
                            if (!&#40;r - 2 & 7&#41;)
                                return y ^= 8, G&#91;h&#93; = O, K;
                            n = o & z;
                            J = I&#91;p - a&#93; & z;
                            t = q | J - 7 ? n &#58; &#40;n += 2, 6 ^ y&#41;;
                            while &#40;n <= t&#41; &#123;
                                p&#91;I&#93; = n, E = O&#91;I&#93; = m ? *g = *m, *m = 0 &#58; g ? *g = 0 &#58; 0;
                                L = &#40;1 - q ? l&#91;p / x + 5&#93; - l&#91;O / x + 5&#93; + l&#91;p % x + 6&#93; - l&#91;O % x + 6&#93; 
                                    + o / 16 * 8 &#58; !!m * 9&#41; + &#40;q ? 0 &#58; l&#91;p % x + 6&#93; - 98 + !&#40;I&#91;p - 1&#93; ^ n&#41; 
                                    + !&#40;I&#91;p + 1&#93; ^ n&#41; + l&#91;n & 7&#93; * 9 - 288 + !!g * 99 + &#40;A < 2 && &#40;E = p&#41;)) 
                                    + &#40;r ? l&#91;r & 7&#93; * 9 - 189 - h - q &#58; 0&#41; + !&#40;J ^ y ^ 9&#41;;
                                if &#40;s > h || s == h & &#40;L > z & 1 < s | d&#41;)
                                    L -= X&#40;G&#91;h + 1&#93;, s > h | d ? 0 &#58; p, L, h + 1, E, N, s&#41;;
                                if (!&#40;h || S | B - O | i - n | p - b | L < -M&#41;)
                                    return u = E;
                                J = q - 1 | A < 7 || m || !s | d | r | o < z || X&#40;21, 0, 0, 0, 0, 1, 0&#41; > M;
                                O&#91;I&#93; = o;
                                p&#91;I&#93; = r;
                                m ? *m = *g, *g = 0 &#58; g ? *g = 9 ^ y &#58; 0;
                                if &#40;L > N&#41; &#123;
                                    N = L;
                                    G&#91;h&#93; = O;
                                    if (!h & s > 1&#41;
                                        i = n, B = O, b = p;
                                    if &#40;h && c - L < S&#41;
                                        return y ^= 8, L;
                                &#125;
                                n += J || &#40;g = I + p, m = p < O ? g - 3 &#58; g + 2, *m < z | I&#91;p += p - O&#93; | m&#91;p < O ? 1 &#58; -1&#93;);
                            &#125;
                        &#125;
                    &#125;
                &#125; while (!r & q > 2 || &#40;p = O, q | A > 2 | o > z & !r && ++C && --A&#41;);
            &#125;
        &#125;
    &#125; while (++O > 98 ? O = 20 &#58; f - O&#41;;
    return y ^= 8, N + M * M && N > -K + 1924 | d ? N &#58; 0;
&#125;

void m1&#40;void&#41;
&#123;
    if (*l - 'u')
        l -= 32, G = I;
    B = y = u = 0;
    while (++B < 121&#41;
        *G++ = B / x % x < 2 | B % x < 2 ? 7 &#58; B / x & 4 ? 0 &#58; *l++ & 31;
&#125;

int main&#40;void&#41;
&#123;
    char            g&#91;80&#93;,
                   *a,
                   *c;
    int             f = 0,
                    j = 0,
                    m;
    clock_t         k;
    
    setbuf&#40;stdout, NULL&#41;;
    setbuf&#40;stdin, NULL&#41;;    
    while &#40;fflush&#40;stdout&#41;, fgets&#40;g, 79, stdin&#41;) &#123;
        a = c = g;
        while &#40;isspace&#40;*a&#41;)
            a++;
        while (*a && *a - 10 && !isspace&#40;*a&#41;)
            *c++ = *a++;
        *c = 0;
        ;
        if (!strcmp&#40;g, "quit"))
            break;
        if (!strcmp&#40;g, "post"))
            j = 1;
        if (!strcmp&#40;g, "nopost"))
            j = 0;
        if (!strcmp&#40;g, "new"))
            f = 0, m1&#40;);
        if (!strcmp&#40;g, "force"))
            f = 1;
        if (!strcmp&#40;g, "go"))
            f = 0;
        if (!strcmp&#40;g, "protover"))
            puts&#40;"feature myname="Toledo Nanochess Mar/25/2009" done=1");
        if &#40;isalpha&#40;g&#91;0&#93;) && isdigit&#40;g&#91;1&#93;) && isalpha&#40;g&#91;2&#93;) && isdigit&#40;g&#91;3&#93;)) &#123;
            a = g;
            B = *a++ & z;
            B += 100 - (*a++ & z&#41; * x;
            b = *a++ & z;
            b += 100 - (*a++ & z&#41; * x;
            i = *a - 'q' ? *a - 'r' ? *a - 'b' ? *a - 'n' ? I&#91;B&#93; & z &#58; 11 ^ y &#58; 12 ^ y &#58; 13 ^ y &#58; 14 ^ y;
            X&#40;21, 0, 0, 0, u, 0, 1&#41;;
            if (!f&#41;
                strcpy&#40;g, "go");
        &#125;;
        if (!strcmp&#40;g, "go")) &#123;
            k = clock&#40;);
            D = 0;
            m = X&#40;21, 0, 0, 0, u, 1, 5&#41;;
            k = &#40;clock&#40;) - k&#41; * 1e2 / 1000;
            a = g;
            *a++ = B % x + 96;
            *a++ = 58 - B / x;
            *a++ = b % x + 96;
            *a++ = 58 - b / x;
            if (&#40;I&#91;B&#93; & z&#41; - i&#41;
                *a++ = "nbrq"&#91;i - 3 & 7&#93;;
            *a = 0;
            ;
            if &#40;j&#41;
                printf&#40;"6 %d %d %d %s\n", m, k, D, g&#41;;
            X&#40;21, 0, 0, 0, u, 0, 1&#41;;
            printf&#40;"move %s\n", g&#41;;

        &#125;
    &#125;
    return 0;
&#125;

I have to admit, that is one tiny Winboard interface module.

zullil
Posts: 5601
Joined: Mon Jan 08, 2007 11:31 pm
Location: PA USA
Full name: Louis Zulli

Re: Released Toledo Nanochess with Winboard interface

Post by zullil » Sat Apr 18, 2009 12:00 pm

Dann Corbit wrote:I must have bonked something when I was fooling around with the source code because I have never seen any engine play this crazy.
I compiled the source (as released) without the Winboard interface, and played from the command line. The same game is generated as the one you posted.

Post Reply