Consolidate evaluation of unpromoted soldiers
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 22 Nov 2019 15:50:36 +0000 (16:50 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 22 Nov 2019 15:50:36 +0000 (16:50 +0100)
xiangqi
LLR: 2.96 (-2.94,2.94) [0.00,10.00]
Total: 1678 W: 615 L: 516 D: 547

src/evaluate.cpp
src/position.cpp

index 85a4c38..9899090 100644 (file)
@@ -307,6 +307,12 @@ namespace {
         // Restrict mobility to actual squares of board
         b &= pos.board_bb();
 
+        if (Pt == SOLDIER && pos.unpromoted_soldier(Us, s))
+        {
+            b &= file_bb(s);
+            score -= make_score(PieceValue[MG][Pt], PieceValue[EG][Pt]) / 3;
+        }
+
         if (pos.blockers_for_king(Us) & s)
             b &= LineBB[pos.square<KING>(Us)][s];
 
@@ -346,9 +352,6 @@ namespace {
         if (pos.captures_to_hand() && pos.count<KING>(Them) && pos.count<KING>(Us))
             score -= KingProximity * distance(s, pos.square<KING>(Us)) * distance(s, pos.square<KING>(Them));
 
-        if (Pt == SOLDIER && pos.unpromoted_soldier(Us, s))
-            score -= make_score(PieceValue[MG][Pt], PieceValue[EG][Pt]) / 2;
-
         if (Pt == BISHOP || Pt == KNIGHT)
         {
             // Bonus if piece is on an outpost square or can reach one
index 92fde7a..e921d83 100644 (file)
@@ -796,6 +796,9 @@ Bitboard Position::attackers_to(Square s, Bitboard occupied, Color c) const {
   if (xiangqi_general())
       b ^= b & pieces(KING) & ~PseudoAttacks[~c][WAZIR][s];
 
+  if (unpromoted_soldier(c, s))
+      b ^= b & pieces(SOLDIER) & ~PseudoAttacks[~c][SHOGI_PAWN][s];
+
   return b;
 }