From 7620bfe3b6263f9bf748062d708aa9cfd6ae6f45 Mon Sep 17 00:00:00 2001 From: ianfab Date: Tue, 26 Jun 2018 22:45:23 +0200 Subject: [PATCH] Scale passed pawn evaluation by promotion piece value 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 | 10 ++++++++++ src/position.h | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index e3a3088..da23236 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -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); diff --git a/src/position.h b/src/position.h index 9ecc7e8..5738427 100644 --- a/src/position.h +++ b/src/position.h @@ -91,7 +91,7 @@ public: File max_file() const; const std::string piece_to_char() const; Rank promotion_rank() const; - std::vector promotion_piece_types() const; + const std::vector& 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 Position::promotion_piece_types() const { +inline const std::vector& Position::promotion_piece_types() const { assert(var != nullptr); return var->promotionPieceTypes; } -- 1.7.0.4