Prevent pawn-drop mates in Shogi
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 15 May 2017 13:15:08 +0000 (15:15 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 15 May 2017 13:15:08 +0000 (15:15 +0200)
In case of a mate we now check if the previous move was a Pawn drop,
and correct the score to a win if we detect one. In Crazyhouse we
test for check, and correct to draw due to stalemate without one.

dropper.c

index e421cba..37111d0 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -1429,6 +1429,12 @@ if(PATH)printf("%d:%d:%d iter end, max=%d, alpha=%d start=%d\n", ply, depth,iter
 
     } while(iterDepth < maxDepth && (ply || !TimeIsUp(1)));   // IID loop
 
+    if(bestScore == -INF) { // we are mated!
+       if(perpLoses) {     // Shogi
+           if(ff->fromSqr == handSlot[stm]) bestScore = INF; // mated by Pawn drop, so we win!
+       } else if(f.checker == CK_NONE) bestScore = 0;        // stalemate in zh is draw
+    }
+
   cutoff:
     // delayed-loss bonus
     bestScore += (bestScore < curEval);