Scale passed pawn evaluation by promotion piece value
authorianfab <ianfab@users.noreply.github.com>
Tue, 26 Jun 2018 20:45:23 +0000 (22:45 +0200)
committerianfab <ianfab@users.noreply.github.com>
Mon, 2 Jul 2018 19:57:12 +0000 (21:57 +0200)
No functional change for standard chess.

Shatranj STC
LLR: 2.95 (-2.94,2.94) [0.00,10.00]
Total: 82 W: 63 L: 1 D: 18

src/evaluate.cpp
src/position.h

index e3a3088..da23236 100644 (file)
@@ -712,6 +712,16 @@ namespace {
         score += bonus + PassedFile[file_of(s)];
     }
 
+    // Scale by maximum promotion piece value
+    Value maxMg = VALUE_ZERO, maxEg = VALUE_ZERO;
+    for (PieceType pt : pos.promotion_piece_types())
+    {
+        maxMg = std::max(maxMg, PieceValue[MG][pt]);
+        maxEg = std::max(maxEg, PieceValue[EG][pt]);
+    }
+    score = make_score(mg_value(score) * int(maxMg) / QueenValueMg,
+                       eg_value(score) * int(maxEg) / QueenValueEg);
+
     if (T)
         Trace::add(PASSED, Us, score);
 
index 9ecc7e8..5738427 100644 (file)
@@ -91,7 +91,7 @@ public:
   File max_file() const;
   const std::string piece_to_char() const;
   Rank promotion_rank() const;
-  std::vector<PieceType> promotion_piece_types() const;
+  const std::vector<PieceType>& promotion_piece_types() const;
   bool double_step_enabled() const;
   bool castling_enabled() const;
   bool checking_permitted() const;
@@ -262,7 +262,7 @@ inline Rank Position::promotion_rank() const {
   return var->promotionRank;
 }
 
-inline std::vector<PieceType> Position::promotion_piece_types() const {
+inline const std::vector<PieceType>& Position::promotion_piece_types() const {
   assert(var != nullptr);
   return var->promotionPieceTypes;
 }