Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dbgboard(char*b){
int i;
for(i=0;i<64;++i){putchar(*b++);if(i%8==7)putchar('\n');}
}
const char*color(t){return t?"black":"white";}
char m[99],*p;t,i;
main(){
char b[65],l[]="\0";sprintf(b,"%s%*s","rnbqkbnrpppppppp",48,"PPPPPPPPRNBQKBNR");
for(;~scanf("%s",p=m);){
if(*p=='O'){
int castle = p[3]=='-';
printf("%s: castle %d: ", color(t), castle);
} else {
char srctype = *p<'Z'?*p++:'P';
for(;isalnum(*p);)++p;
char dsttype = *p^'='?srctype^t:p[1];
int dst = 8*(7-(p[-1]-'1'))+p[-2]-'a'; p-=3+(p[-3]=='x');
int row = *p&&*p<'9'?7-(*p---'1'):-1;
int col = *p>'`'?*p-'a':-1;
printf("%s: moving %c as %c: to %d ", color(t), srctype, dsttype, dst);
if (~row)printf("(row %d) ", row);
if (~col)printf("(col %d) ", col);
// for(i=0;i<64;++i){
// }
}
puts(m);
t^=32;
}
for(i=0;i<64;)*l=b[i]^' '?0*printf("%s%c",l,b[i]):1+*l|'0',*l=i++%8>6?0*printf("%s%s",l,"/"+(i>63)):*l;
puts("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.