Not really micro but anyway, if someone is interested to experiment in deep learning, I just published an application that I hope should allow people to quick start in chess related area: https://github.com/stevexyz/SlyMlego ...
Happy hacking!
It was a long time that I was willing to realize SuperMicro for the ZX81. The last x86 challenge distracted me from the original scope, but I didn't forget it and ... here it is! :)
Finally the ZX81 1K is able to play chess with the full FIDE rules, as usual including under-promotion, castling and en-passant!
There are not fixed moves. User can pick up every move of each color or let the computer decide for each one its best one!... read more
As promised here we are with the mini realease!
This version doesn't manage castling, underpromotion, and en passant; is playing just one side (black selected), has the "usual" algebraic move interface, but... everythng fits in 455 bytes! And do not think that will be so easy to defeat it!
Just remember to not press enter and to not perform illegal moves (the computer won't).
And now, happy Super Micro Mini chess! :)
_Stefano... read more
Each time I look back at the source code I'm able to shave some more bytes. Even if this is becoming increasingly difficult I was again able to shrink the full FIDE version, this time up to 740 characters of source code (spaces included) in 35 lines!
But this post is for another release...
Is a long time that I was willing test the other size challenge: the executable program. I was already preparing myself to challenge the famous 1K chess on its own ground (the ZX81 computer) but the BootChess release changed the landscape, and made it even more challenging!... read more
Recently didn't have any time to evolve the project, but anyway here it is the tiniest "standard" Super Micro evolved during the "full" version development: 678 bytes, exactly other 100 bytes less than the last one released... and try to beat it! :)
As usual here the pretty printed version (inside the code there is move generation, move evaluation, best move tree search, initial board setup, board display, user input and legal move check).... read more
First release of Super Micro FIDE version with embedded Winboard chess engine interface, for now all within 938 bytes!
This release come together with his twin with standard custom character interface that shrunk again landing at 760 bytes!
This Winboard version is esperimental and there is just a minimal protocol management, but finally should make the play and test much easier! :)
(with an opening book the play will be a bit more interesting since little strategic knowledge has been embedded in the little pet!)... read more
This is making this release the smallest ever, since the correspondent simplified and enhanced "standard" super micro (that is around 100 bytes less) has not beem released since is under debug (I was just focusing on this "full" version)! :)
Following the 39 lines of the full source code pretty printed thanks to AStyle application:
~~~~~~
M=136,C=799,K=8,X,Y;
char c[9],b[128]="VSUWTUSV";
D(k,x,n)
{ int i=0,j,t,p,u,r,y,m=-C,v;
do
{ if((u=b[i])&k)
{ j=".H?LFICF"[p=r=u&7]-64;
while(r=p>2&r<0?-r:64-"01/@AP@ABPOQ@NR_a@"[++j])
{ y=i;
do
{ t=b[y+=r];
if((p==7|!x)&&j==8||!(r&7)-!t&p<3|t&k||y&M)break;
v=t&k?1:" !!#~#%)"[t&7]-32;
if(n&&v<64)
{ b[i]=0,b[y]=u;
if(p<3&&y+r+1&128)b[y]=(c&&c[4]?c[4]:55)-48|k,v+=9;
v-=D(24-k,2,n-1);
if(x&1&&v>-64&&i==X&y==Y)
{ if(j==8)b[y+(r>>2^1)]=0,b[y-r/2]=6|k;
return 0; }
b[i]=u,b[y]=t; };
if(v>m)
{ m=v;
if(n>3)X=i,Y=y; }
t+=p<5;
if(x&1&&(y&112)+6k==128&p<3)t--; }
while(!t); } } }
while(i=i+9&~M);
return m; }
main()
{ X=8;
while(X--)b[X+112]=(b[X]-=64)-8,b[X+16]=18,b[X+96]=9;
while(1)
{ X=128;
while(X--)putchar(X&8&&(X-=7)?10:".?+nkbrq??NKBRQ"[b[X]&15]);
gets(c);
X=c-16c[1]+C,Y=c[2]-16c[3]+C;
if(!*c)D(K,0,4);
if(!D(K,1,1))K^=24; } }
~~~~~~... read more
As understandable the recent iterations were able to gain less than the initial ones, and I started thinking that with current size it could be the moment to put inside the full fide rules for playing standard games. But before starting to add, I thought to do a last deep iteration and only then complete the code with the missing logic for castling, en-passant and under-promotion.
So this weekend I did it and... I removed 70 character!! (I had to intervene in a lot of places, almost everywhere, including improving the evaluation routine!) But more, I started thinking about the way to let Super Micro understand the full fide rules in the "smallest" way possible and... started implementing the ideas... finishing to fit everything in 799 bytes (all still ascii printable ones)!!... read more
Other 5 characters have been removed!
This was made possible with some intervention to the board setup and the user interface: now the table is printed with a "black perspective" (with the a1 corner on top right and the h8 on bottom left) and the user input is asked just to the right of the updated table printed (with the sequence of tables always nicely spaced)
I made another shrinking session and in three steps I removed other 6 characters (and 4 lines).
I also added an icon file. And just to give an idea of the tiny size of the program: the little 32x32 pixel icon file is 4 times bigger than the full source code file and even bigger than the program executable file itself! (the 48x48 pixel icon that I removed was even 3 times bigger than the 32x32 one!)... read more
Other 9 characters have been "shaved" :)
Now the source is The Smallest up to now: 789 bytes!
Following the 69 lines pretty printed:
~~~~~~
M=136,C=799,X,Y;
chard="120ABQABQPRAOS`bABBD@DFJH@LGIDG",K=8,c[9],b[128]="B?AC@A?B";
D(k,x,e,n) {
int i=0,j,t,p,u,r,y,m=n?-C:e,v;
do {
u=b[i];
if(u&k) {
r=p=u&7;
j=d[p+23]-65;
while(r=p>2&r<0?-r:65-d[++j]) {
y=i;
do {
y+=r;
t=b[y];
if(t&k|p<3&!(r&7)-!t||y&M)break;
v=M;
v=d[t&7|16]-65;
if(v<0)m=C;
if(n) {
b[i]=0;
b[y]=u;
if(p<3) {
v-=9((i-2&M||b[i-2]!=u)+(i+2&M||b[i+2]!=u)-1);
if(y+r+1&128) {
b[y]|=7;
v+=C;
}
}
v=-D(24-k,y,-e-v,n-1);
v-=v>C/3;
if(x==9) {
if(v+C&&i==X&y==Y) return 0;
v=m;
}
b[i]=u;
b[y]=t;
if(v>m) {
m=v;
if(x&8) {
X=i;
Y=y;
}
}
}
t+=p<5;
if(p<3&6k+(y&112)==128)t--;
} while(!t);
}
}
} while(i=i+9&~M);
return m;
}
main() {
X=-1;
while(++X<8) {
b[X+112]=(b[X]-=44)-8;
b[X+16]=18;
b[X+96]=9;
}
while(1) {
X=-1;
while(++X<121) putchar(X&8&&(X+=7)?10:".?+nkbrq??NKBRQ"[b[X]&15]);
gets(c);
X=c-16c[1]+C;
Y=c[2]-16c[3]+C;
if(!*c) D(K,8,0,4);
if(!D(K,9,0,1)) K^=24;
}
}
~~~~~~... read more
While releasing the executable version I discovered a little bug and so I made the first (official! ;)) bug-fix release.
Source code increased overall 1 character (now it is 798 bytes), and hope there are no more inside! :)
Good wind to everyone!
_Stefano
Actual file got as small as 797 bytes!!
(69 very short lines, and still all printable ascii characters!)
And I'm sure some more bytes will come out! ;)
Good chess to everyone!
_Stefano
Now the source is even smaller: 810 characters!
And for the ones that do not like the defines (naturally just from an aesthetic point of view!) there is a 815 characters version that do not use them! ;)
There is space to reduce more? Who knows! Next challenge less than 800!
Cheers!
_Stefano
Few months ago thanks to the GameKnot website (ref: http://gameknot.com/#stevexyz), that allow to make one single move in few days making it possible to play it reasoning and when you have time, I got passionate about chess. And then I got curious about chess engines (since I had an idea for an evaluation routine I thought was good). And trying to document myself about this "world" I found the amazing Micro-Max chess engine by H.G.Muller (ref: http://home.hccnet.nl/h.g.muller/max-src2.html), that in less than 1200 characters was including the engine and even the user interface!... read more