Allow RxK notation for entering castling
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 22 Nov 2010 11:52:02 +0000 (12:52 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 22 Nov 2010 12:12:43 +0000 (13:12 +0100)
This notation is detected on input, and translated to the corresponding
King move, where the to-square is derved from the entered 'Rook'
position, so that capturing with wrongly positioned pieces would be
rejected as illegal. (They might be accepted as normal King moves,
though.)

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