Fix futility pruning
[hachu.git] / hachu.c
diff --git a/hachu.c b/hachu.c
index 0c8a239..a8828c5 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -1909,7 +1909,11 @@ if(PATH) printf("%d:%2d:%2d next victim %d/%d\n",level,depth,iterDep,curMove,msp
              if(to == ABSENT) continue;              // ignore if absent\r
              if(!attacks[2*to + stm]) continue;      // skip if not attacked\r
              group = p[nextVictim].value;            // remember value of this found victim\r
-             if(iterDep <= QSdepth + 1 && 2*group + curEval + 30 < alpha) { resDep = QSdepth + 1; goto cutoff; }\r
+             if(iterDep <= QSdepth + 1 && 2*group + curEval + 30 < alpha) {\r
+               resDep = QSdepth + 1; nextVictim -= 2;\r
+               if(bestScore < 2*group + curEval + 30) bestScore = 2*group + curEval + 30;\r
+               goto cutoff;\r
+             }\r
 if(PATH) printf("%d:%2d:%2d group=%d, to=%c%d\n",level,depth,iterDep,group,to%BW+'a',to/BW+ONE);\r
              GenCapts(to, 0);\r
 if(PATH) printf("%d:%2d:%2d first=%d msp=%d\n",level,depth,iterDep,firstMove,msp);\r