New 'Micro' Chess Engine - Iota 0.1

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
abik
Posts: 824
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by abik »

Nice! I compiled this for ARM-based Android devices, and the result is about 18KB. With your explicit permission, I can post the binary on UCI and XBoard engines for Android.

Code: Select all

-rwxr-xr-x shell    shell       18940 2012-07-07 13:05 iota
User avatar
Jim Ablett
Posts: 2390
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by Jim Ablett »

Mincho Georgiev wrote:Sorry, I didn't saw that you already use tcc. Otherwise I would be surprised by the 30k size /obiously the size optimization fixed this/. tcc and pelle's where the compilers that I was able to produce smallest win executables with. The only compilers for smaller windows executable that I have been used are masm and nasm, irrelevant in this case though.
Size of 30kb was for GCC. TCC was 3.50 kb

Jim.
Daniel White
Posts: 33
Joined: Wed Mar 07, 2012 4:15 pm
Location: England

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by Daniel White »

abik wrote:Nice! I compiled this for ARM-based Android devices, and the result is about 18KB. With your explicit permission, I can post the binary on UCI and XBoard engines for Android.

Code: Select all

-rwxr-xr-x shell    shell       18940 2012-07-07 13:05 iota
You have my permission, although be warned that it plays extremely weak on a desktop computer, never mind a mobile... Hopefully later versions can change this.
User avatar
abik
Posts: 824
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by abik »

Daniel White wrote:You have my permission, although be warned that it plays extremely weak on a desktop computer, never mind a mobile... Hopefully later versions can change this.
Thanks!

May I suggest changing

Code: Select all

   printf("bestmove %c%i%c%i%c\n", t%16+97, t/16+1, u%16+97, u/16+1, 
             ((B[t]%8==2 && (u/16==0 || u/16==7)) ? 'q' : 0)); } 
into (sorry for the two extra characters), to avoid potential GUI confusion on the null character?

Code: Select all

   printf("bestmove %c%i%c%i%c\n", t%16+97, t/16+1, u%16+97, u/16+1, 
             ((B[t]%8==2 && (u/16==0 || u/16==7)) ? 'q' : ' ')); } 
Daniel White
Posts: 33
Joined: Wed Mar 07, 2012 4:15 pm
Location: England

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by Daniel White »

abik wrote:
Daniel White wrote:You have my permission, although be warned that it plays extremely weak on a desktop computer, never mind a mobile... Hopefully later versions can change this.
Thanks!

May I suggest changing

Code: Select all

   printf("bestmove %c%i%c%i%c\n", t%16+97, t/16+1, u%16+97, u/16+1, 
             ((B[t]%8==2 && (u/16==0 || u/16==7)) ? 'q' : 0)); } 
into (sorry for the two extra characters), to avoid potential GUI confusion on the null character?

Code: Select all

   printf("bestmove %c%i%c%i%c\n", t%16+97, t/16+1, u%16+97, u/16+1, 
             ((B[t]%8==2 && (u/16==0 || u/16==7)) ? 'q' : ' ')); } 
Ah yes I hadn't considered that. Although we can use 32 instead of ' ' to add only a single character. I'm sure that line can be improved anyway.

Edit: This should do it:

Code: Select all

(B[t]%8==2 & (u+u-t+1&128) ? 'q' : 32)); }
Daniel White
Posts: 33
Joined: Wed Mar 07, 2012 4:15 pm
Location: England

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by Daniel White »

Jim Ablett wrote:
Mincho Georgiev wrote:
Jim Ablett wrote:
Edmund wrote:
Jim Ablett wrote:Hi Daniel,

Very well done. It's quite remarkable you can get working engine in such a small amount of code.

I compiled a very small windows executable using Tiny C + Upx compression and got the binary size down to an incredible 3.50 kb.

I named it 'Iota' to avoid confusion with other engine.

https://dl.dropbox.com/u/5047625/iota-10-32-tcc-ja.zip

Jim.
I thought Tiny C was just notable for the small size of the compiler, not the size of its compiles. Couldn't you get better results with intel compiler optimizing for size?

Smallest size I can get with GCC (inc compression) is 26.5kb
Smallest size I can get with Intel (inc compression) is 30.0kb

Ok my challenge is for someone to produce a windows exe smaller than 3.50 kb

Jim.
Try this, Jim:

http://bellard.org/tcc/
or
http://www.smorgasbordet.com/pellesc/
Hi Mincho,

Tcc is what I used.

Pelles C throws up a few errors and won't compile.

Code: Select all

C:\temp\iota.c(57): warning #2099: Missing type specifier; assuming 'int'.
C:\temp\iota.c(60): warning #2027: Missing prototype for 'strtok'.
C:\temp\iota.c(60): warning #2241: The function 'gets' is marked as deprecated.
C:\temp\iota.c(61): warning #2027: Missing prototype for 'strncmp'.
C:\temp\iota.c(62): warning #2027: Missing prototype for 'strncmp'.
C:\temp\iota.c(63): warning #2027: Missing prototype for 'strncmp'.
C:\temp\iota.c(64): warning #2027: Missing prototype for 'strncmp'.
C:\temp\iota.c(71): error #2168: Operands of '=' have incompatible types 'char *' and 'int'.
C:\temp\iota.c(71): warning #2030: '=' used in a conditional expression.
C:\temp\iota.c(72): warning #2027: Missing prototype for 'strncmp'.
C:\temp\iota.c(73): error #2168: Operands of '=' have incompatible types 'char *' and 'int'.
C:\temp\iota.c(73): warning #2030: '=' used in a conditional expression.
C:\temp\iota.c(74): warning #2027: Missing prototype for 'strcmp'.
C:\temp\iota.c(74): error #2140: Type error in argument 1 to '__stoul'; expected 'const char *' but found 'int'.
Jim.
I think those errors could be fixed by adding '#include <string.h>' at the top (although this obviously adds a lot of characters which are unneeded in GCC).
User avatar
abik
Posts: 824
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by abik »

Daniel White wrote:You have my permission, although be warned that it plays extremely weak on a desktop computer, never mind a mobile... Hopefully later versions can change this.
Quick tournament in Chess for Android against similar engines. Since Iota takes about 10 seconds per move on my Nexus One, I gave the other engines the same amount of time per move. Played with 10 random openings from built-in book.

The Iota binary for ARM-based Android devices can be found at UCI and XBoard engines for Android.

Code: Select all

Iota - Chess for Android     0.0 - 10.0   +0/-10/=0   0.00%
Iota - umax48w               0.5 - 9.5    +0/-9/=1    5.00%
Iota - DeepBrutePos v1.6     9.5 - 0.5    +9/-0/=1    95.00%
petero2
Posts: 733
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by petero2 »

Daniel White wrote:
abik wrote:May I suggest changing

Code: Select all

   printf("bestmove %c%i%c%i%c\n", t%16+97, t/16+1, u%16+97, u/16+1, 
             ((B[t]%8==2 && (u/16==0 || u/16==7)) ? 'q' : 0)); } 
into (sorry for the two extra characters), to avoid potential GUI confusion on the null character?

Code: Select all

   printf("bestmove %c%i%c%i%c\n", t%16+97, t/16+1, u%16+97, u/16+1, 
             ((B[t]%8==2 && (u/16==0 || u/16==7)) ? 'q' : ' ')); } 
Ah yes I hadn't considered that. Although we can use 32 instead of ' ' to add only a single character. I'm sure that line can be improved anyway.

Edit: This should do it:

Code: Select all

(B[t]%8==2 & (u+u-t+1&128) ? 'q' : 32)); }
You could also use 9, which is a TAB character. The UCI specification says this is allowed.
Daniel White
Posts: 33
Joined: Wed Mar 07, 2012 4:15 pm
Location: England

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by Daniel White »

abik wrote:
Daniel White wrote:You have my permission, although be warned that it plays extremely weak on a desktop computer, never mind a mobile... Hopefully later versions can change this.
Quick tournament in Chess for Android against similar engines. Since Iota takes about 10 seconds per move on my Nexus One, I gave the other engines the same amount of time per move. Played with 10 random openings from built-in book.

The Iota binary for ARM-based Android devices can be found at UCI and XBoard engines for Android.

Code: Select all

Iota - Chess for Android     0.0 - 10.0   +0/-10/=0   0.00%
Iota - umax48w               0.5 - 9.5    +0/-9/=1    5.00%
Iota - DeepBrutePos v1.6     9.5 - 0.5    +9/-0/=1    95.00%
Woo it actually won a game :D. Also the time management is based on the assumption of a fixed nps at all times on all devices. If it does become a problem (because either you have a very fast, or very slow device) you can modify line 71:

Code: Select all

if (!strcmp(i+1, "time") & *i==(M&64?119:98)) l=atoi(X)<<9;
The <<9 is what controls how many nodes it searches for, increasing this number by one will double the amount of time it searches, likewise decreasing will half it.
User avatar
JuLieN
Posts: 2949
Joined: Mon May 05, 2008 12:16 pm
Location: Bordeaux (France)
Full name: Julien Marcel

Re: New 'Micro' Chess Engine - Yoda 0.1

Post by JuLieN »

Daniel White wrote: Iota is fine by me! I'll update the original post now... (edit: turns out I'm not allowed to do so)
Hi Daniel, and congrats for this beautiful achievement! :shock:

I changed the name to "Iota" in the thread's title, which is what I believe you wanted to do :)
"The only good bug is a dead bug." (Don Dailey)
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]