Implement initiative bonus
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 7 Feb 2017 21:33:53 +0000 (22:33 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 7 Feb 2017 21:33:53 +0000 (22:33 +0100)
An initiative bonus is awarded to the side to move, based on seige of
the opponent King and own pieces in hand. A second attempt to stand pat
on the score including this bonus is then made.

dropper.c

index 7b65c34..9081a17 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -1222,6 +1222,18 @@ if(hashMove && board[hashMove>>8&255] == 0) {char s[100];sprintf(s,"bad hash mov
        }
     }
 
+    if(depth <= 0) {
+       int bonus = (m.safety + 3*m.hole)*(10 + m.safety + m.hole + promoGain[stm+30] /*- 0*promoGain[COLOR-stm+30]*/) + 15*m.cBonus;
+       bonus += (m.escape < 2 ? 200 - m.escape*100 : 0);
+       if(bonus > 900) bonus = 900; // S4
+       bonus += bonus >> 1;
+       int newEval = curEval + bonus;
+       if(newEval > alpha) {
+           if(newEval >= beta) { ff->depth = 1; moveSP = oldSP; return newEval; } // stand-pat cutoff
+           alpha = startScore = newEval; maxDepth = 0; // we will not fail low, so no extra iterations
+       }
+   }
+
     do { // IID loop
        int curMove, highDepth;
        iterDepth++;