int N,M=136,S=128,I=8e3,X,Y,O,Q,b[129]={6,3,5,7,4,5,3,6};
char*q="@A?PQ`PQ`_aP^boqPQQSOSUYWO[VXSV",*n=".?+nkbrq?*?NKBRQ";
D(k,w,l,e,E,x,d){
int j,t,p,u,r,y,i=0,m=d>1|w>e?w:e,v,h,z,F,G,H;N++;
do{u=b[i];if(u&k){r=p=u&7;j=q[p+23]-80;
while(r=p>2&r<0?-r:80-q[++j]){y=i;F=G=S;
do{H=y+=r;if(y&M)break;if(p<3&y==E)H^=16;
t=b[H];if(t&k|p<3&!(r&7)-!t)break;v=99*(q[t&7|16]-80);
if(v<0)m=I;if(m>=l)return m;
if(h=d-(y!=x)){v+=i%8-y%8;
b[G]=b[H]=b[i]=0;b[y]=u&31;G&M||(b[F]=k+6,v+=30);
v=-D(24-k,-l,-m,z=-e-v,F,y,h);
if(x==9){if(v+I&&i==X&y==Y){Q=z;O=F;return l;}v=m;}
b[G]=k+38;b[F]=b[y]=0;b[i]=u;b[H]=t;
v>m&&(m=v,x&8&&(X=i,Y=y));
}t+=p<5;p<3&&6*k+(y&112)==S
||(u&~24)==36&j==7&&G&M&&b[G=(i|7)-(r>>1&7)]&32
&&!b[G^1]&!b[G^2]?F=y,t--:0;
}while(!t);}}}while(i=i+9&~M);return m;}
main(){int k=8,d;char c[9];
for(O=S,X=8;X--;){b[X+112]=(b[X]+=48)-8;b[X+16]=18;b[X+96]=9;}
for(;;){for(X=0;X<121;X++)printf("%c",X&8&&(X+=7)?10:n[b[X]&15]);
gets(c);if(*c)X=*c-16*c[1]+799,Y=c[2]-16*c[3]+799;
else for(d=N=2;N<1e6;)D(k,-I,I,Q,O,8,d++);
if(D(k,-I,I,Q,O,9,2)+I)k^=24;}}As you write: not implemented: castling, en passant, promotion, repetition, 50-move rule - those are all required to call the game being played modern chess.
I could see an argument for skipping repetition and 50-move rule for tiny engines, but you do need castling, en pessant and promotion for pretty much any serious play.
https://en.wikipedia.org/wiki/Video_Chess fit in 4k and supported fuller ruleset in 1980 did it not?
So I would ask what is the smallest fully UCI (https://www.chessprogramming.org/UCI) compliant engine available currently?
This would be a fun goal to beat - make something tiny that supports full ruleset.
PS my first chess computer in early 1980s was this: https://www.ismenio.com/chess_fidelity_cc3.html - it also supported castling, en pessant, not sure about 50 move rule.
Bug report:
a b c d e f g h
8 r n b q k b n r 8
7 . . p p p p p p 7
6 . p . . . . . . 6
5 p . . . . . . . 5
4 P . . P P . . . 4
3 . . . . . . . . 3
2 . P P . . P P P 2
1 R N B Q K B N R 1
a b c d e f g h
move: b2b3
ai: b6b4
The pawn is not permitted to move two fields after it has already beeen moved once before: b6b4 isn't a valid move after b7b6. (First moving two fields, and then one would have been okay, in contrast.)[1] https://github.com/thomasmueller/bau-lang/blob/main/src/test...
[2] https://www.chessprogramming.org/Sequential_Probability_Rati...
Do you work with it like this or do you have some sort of script you apply to get it down to a single line, single letter variable names?
P.S. I assume 1200 elo in chess com scale (not lichess / fide elo) and bullet chess variant?
The gap between your 1200 Elo in 2KB and the TCEC 4K engines at ~3000 Elo is interesting. That extra 2KB buys a lot when it goes to better evaluation and move ordering. Even a simple captures-first sort in alpha-beta pruning costs only a few bytes of code but can roughly double your effective search depth.