From 4b753a4ed5a531703e7456cb92f21b9a0f46b4e3 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 22 Nov 2010 12:52:02 +0100 Subject: [PATCH] Allow RxK notation for entering castling 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 | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fairymax.c b/fairymax.c index ce2d7ae..7fb3cad 100644 --- a/fairymax.c +++ b/fairymax.c @@ -859,14 +859,18 @@ int main(int argc, char **argv) if (m) /* doesn't have move syntax */ printf("Error (unknown command): %s\n", command); - else if(D(Side,-I,I,Q,O,LL|S,3)!=I) { + else { int i=K; + if(b[L] && (b[L]&16) == Side && w[b[L]&15] < 0) // capture own King: castling + { K = L; L = i>L ? i-1 : i+2; } + if(D(Side,-I,I,Q,O,LL|S,3)!=I) { /* did have move syntax, but illegal move */ printf("Illegal move:%s\n", line); - } else { /* legal move, perform it */ + } else { /* legal move, perform it */ GameHistory[GamePtr++] = PACK_MOVE; Side ^= BLACK^WHITE; CopyBoard(HistPtr=HistPtr+1&1023); if(PrintResult(Side)) Computer = EMPTY; + } } } } -- 1.7.0.4