Breakthrough bonus for horde chess
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 23 Oct 2020 10:07:20 +0000 (12:07 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 23 Oct 2020 10:07:19 +0000 (12:07 +0200)
horde STC
LLR: 2.97 (-2.94,2.94) [0.00,10.00]
Total: 783 W: 443 L: 330 D: 10
http://www.variantfishtest.org:6543/tests/view/5f91d5366e23db221d9e9342

horde LTC
LLR: 2.95 (-2.94,2.94) [0.00,10.00]
Total: 644 W: 375 L: 264 D: 5
http://www.variantfishtest.org:6543/tests/view/5f91ee7f6e23db221d9e9345

src/evaluate.cpp

index 9ebb9fc..b5e6270 100644 (file)
@@ -1157,6 +1157,21 @@ namespace {
                     score -= make_score(30, 30) * m / (1 + l * r);
                 }
             }
+            else if (pos.count<PAWN>(Them) == pos.count<ALL_PIECES>(Them) && pos.pieces(Us, ROOK, QUEEN))
+            {
+                // Add a bonus according to how close we are to breaking through the pawn wall
+                int dist = 8;
+                if ((attackedBy[Us][QUEEN] | attackedBy[Us][ROOK]) & rank_bb(relative_rank(Us, pos.max_rank(), pos.max_rank())))
+                    dist = 0;
+                else for (File f = FILE_A; f <= pos.max_file(); ++f)
+                {
+                    int pawns = popcount(pos.pieces(Them, PAWN) & file_bb(f));
+                    int pawnsl = std::min(popcount(pos.pieces(Them, PAWN) & shift<WEST>(file_bb(f))), pawns);
+                    int pawnsr = std::min(popcount(pos.pieces(Them, PAWN) & shift<EAST>(file_bb(f))), pawns);
+                    dist = std::min(dist, pawnsl + pawnsr);
+                }
+                score += make_score(50, 50) * pos.count<PAWN>(Them) / (1 + dist) / (pos.pieces(Us, QUEEN) ? 2 : 4);
+            }
     }
 
     // Connect-n