Merge pull request #8 from glinscott/master
authormcostalba <mcostalba@gmail.com>
Thu, 22 Mar 2012 06:39:53 +0000 (23:39 -0700)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 22 Mar 2012 06:49:11 +0000 (07:49 +0100)
Optimize undefended minor check. Little editing by
me, no change even at assembly level.

No regression after 8K games at fast TC on a 64bit CPU.

src/evaluate.cpp

index 9bd403e1bf8ab1100284eec6d27f791f5b3b6bcc..2903c4b375da81736478ee3fb6439e6f2f749c08 100644 (file)
@@ -683,19 +683,17 @@ Value do_evaluate(const Position& pos, Value& margin) {
     Score score = SCORE_ZERO;
 
     // Undefended minors get penalized even if not under attack
-    const Bitboard undefended =  pos.pieces(Them)
-                              & (pos.pieces(BISHOP) | pos.pieces(KNIGHT))
-                              & ~ei.attackedBy[Them][0];
-    if (undefended) {
-        score += UndefendedMinorPenalty;
-        if (!single_bit(undefended))
-            score += UndefendedMinorPenalty;
-    }
+    Bitboard undefended =  pos.pieces(Them)
+                         & (pos.pieces(BISHOP) | pos.pieces(KNIGHT))
+                         & ~ei.attackedBy[Them][0];
+    if (undefended)
+        score += single_bit(undefended) ? UndefendedMinorPenalty
+                                        : UndefendedMinorPenalty * 2;
 
     // Enemy pieces not defended by a pawn and under our attack
-    const Bitboard weakEnemies =  pos.pieces(Them)
-                               & ~ei.attackedBy[Them][PAWN]
-                               & ei.attackedBy[Us][0];
+    Bitboard weakEnemies =  pos.pieces(Them)
+                          & ~ei.attackedBy[Them][PAWN]
+                          & ei.attackedBy[Us][0];
     if (!weakEnemies)
         return score;