X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=341b50682f64dac590dd07ac89917c1a25fa8b1a;hb=b8e6f83cfb913fa079edd3690a8720f09eb7b388;hp=ede94ec0d7beaaeaf5d34b2d035a961fc7dde37c;hpb=db229504e2c68a92177985bfbf7a870349257301;p=stockfish
diff --git a/src/evaluate.cpp b/src/evaluate.cpp
index ede94ec0..341b5068 100644
--- a/src/evaluate.cpp
+++ b/src/evaluate.cpp
@@ -17,10 +17,10 @@
along with this program. If not, see .
*/
+#include
#include
#include
#include
-#include
#include "bitcount.h"
#include "evaluate.h"
@@ -158,6 +158,9 @@ namespace {
S(0, 0), S(0, 0), S(56, 70), S(56, 70), S(76, 99), S(86, 118)
};
+ // Hanging[side to move] contains a bonus for each enemy hanging piece
+ const Score Hanging[2] = { S(23, 20) , S(35, 45) };
+
#undef S
const Score Tempo = make_score(24, 11);
@@ -527,7 +530,7 @@ namespace {
if (undefendedMinors)
score += UndefendedMinor;
- // Enemy pieces not defended by a pawn and under our attack
+ // Enemies not defended by a pawn and under our attack
weakEnemies = pos.pieces(Them)
& ~ei.attackedBy[Them][PAWN]
& ei.attackedBy[Us][ALL_PIECES];
@@ -535,13 +538,18 @@ namespace {
// Add a bonus according if the attacking pieces are minor or major
if (weakEnemies)
{
- b = weakEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
+ b = weakEnemies & (ei.attackedBy[Us][PAWN] | ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
if (b)
score += Threat[0][type_of(pos.piece_on(lsb(b)))];
b = weakEnemies & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]);
if (b)
score += Threat[1][type_of(pos.piece_on(lsb(b)))];
+
+ b = weakEnemies & ~ei.attackedBy[Them][ALL_PIECES];
+ if (b)
+ score += more_than_one(b) ? Hanging[Us != pos.side_to_move()] * popcount(b)
+ : Hanging[Us == pos.side_to_move()];
}
if (Trace)
@@ -783,7 +791,7 @@ namespace {
Value v = mg_value(score) * int(ei.mi->game_phase())
+ eg_value(score) * int(PHASE_MIDGAME - ei.mi->game_phase()) * sf / SCALE_FACTOR_NORMAL;
- v /= PHASE_MIDGAME;
+ v /= int(PHASE_MIDGAME);
// In case of tracing add all single evaluation contributions for both white and black
if (Trace)