Allow RxK notation for entering castling
[fairymax.git] / fairymax.c
index ce2d7ae..7fb3cad 100644 (file)
@@ -859,14 +859,18 @@ int main(int argc, char **argv)
                 if (m)\r
                         /* doesn't have move syntax */\r
                        printf("Error (unknown command): %s\n", command);\r
-                else if(D(Side,-I,I,Q,O,LL|S,3)!=I) {\r
+                else { int i=K;\r
+                    if(b[L] && (b[L]&16) == Side && w[b[L]&15] < 0) // capture own King: castling\r
+                    { K = L; L = i>L ? i-1 : i+2; }\r
+                    if(D(Side,-I,I,Q,O,LL|S,3)!=I) {\r
                         /* did have move syntax, but illegal move */\r
                         printf("Illegal move:%s\n", line);\r
-                } else {  /* legal move, perform it */\r
+                    } else {  /* legal move, perform it */\r
                         GameHistory[GamePtr++] = PACK_MOVE;\r
                         Side ^= BLACK^WHITE;\r
                         CopyBoard(HistPtr=HistPtr+1&1023);\r
                         if(PrintResult(Side)) Computer = EMPTY;\r
+                   }\r
                }\r
        }\r
 }\r