From f889e98412098c0bf11ce0802d254f6efcd7d248 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sun, 11 Feb 2018 12:14:28 +0100 Subject: [PATCH] Fix castling through check Castling through check, like walking into check, is supposed to be tested through early move generation in the reply node. But this early generation was triggered by testing whether the 'to-piece' was a King, while the way castling is implemented promotes the King to a Rook. This way castling escaped the test. Now early move generation is done based on the from-piece. --- dropper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dropper.c b/dropper.c index a2d9e3d..766bfa2 100644 --- a/dropper.c +++ b/dropper.c @@ -1119,7 +1119,7 @@ Search (int stm, int alpha, int beta, StackFrame *ff, int depth, int reduction, int curEval, anaEval, score; // legality - int earlyGen = (ff->toPiece == stm+31); // King was moved + int earlyGen = (ff->fromPiece == stm+31); // King was moved if(ply > 90) { if(DEBUG) Dump("maxply"); ff->depth = 0; return -ff->newEval+150; } f.xking = location[stm+31]; // opponent King, as stm not yet toggled if(!earlyGen && ff->mutation > 0) { // if other piece was moved (not dropped!), abort with +INF score if it was pinned -- 1.7.0.4