Add bonus for potential piece promotions
authorFabian Fichter <ianfab@users.noreply.github.com>
Wed, 31 Oct 2018 17:38:21 +0000 (18:38 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Wed, 31 Oct 2018 17:40:30 +0000 (18:40 +0100)
shogi
ELO: 21.57 +-20.7 (95%) LOS: 98.0%
Total: 1000 W: 490 L: 428 D: 82

euroshogi
ELO: 36.62 +-21.1 (95%) LOS: 100.0%
Total: 1000 W: 528 L: 423 D: 49

minishogi
ELO: 39.08 +-16.9 (95%) LOS: 100.0%
Total: 1000 W: 363 L: 251 D: 386

src/evaluate.cpp

index e985b8a..0235745 100644 (file)
@@ -341,6 +341,14 @@ namespace {
         else
             mobility[Us] += make_score(300, 300) * (mob - 2) / (10 + mob);
 
+        // Piece promotion bonus
+        if (pos.promoted_piece_type(Pt) != NO_PIECE_TYPE)
+        {
+            if (promotion_zone_bb(Us, pos.promotion_rank(), pos.max_rank()) & (b | s))
+                score += make_score(PieceValue[MG][pos.promoted_piece_type(Pt)] - PieceValue[MG][Pt],
+                                    PieceValue[EG][pos.promoted_piece_type(Pt)] - PieceValue[EG][Pt]) / 5;
+        }
+
         // Penalty if the piece is far from the king
         if (pos.count<KING>(Us))
             score -= KingProtector[Pt - 2] * distance(s, pos.square<KING>(Us));