Fix undefined behavior for large-board variants
authorFabian Fichter <ianfab@users.noreply.github.com>
Wed, 23 Dec 2020 10:50:49 +0000 (11:50 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Wed, 23 Dec 2020 10:50:49 +0000 (11:50 +0100)
Partly addresses #213.

src/evaluate.cpp

index 8b16477..98b2145 100644 (file)
@@ -550,7 +550,7 @@ namespace {
                 // when the bishop is outside the pawn chain.
                 Bitboard blocked = pos.pieces(Us, PAWN) & shift<Down>(pos.pieces());
 
-                score -= BishopPawns[edge_distance(file_of(s))] * pos.pawns_on_same_color_squares(Us, s)
+                score -= BishopPawns[edge_distance(file_of(s), pos.max_file())] * pos.pawns_on_same_color_squares(Us, s)
                                      * (!(attackedBy[Us][PAWN] & s) + popcount(blocked & CenterFiles));
 
                 // Penalty for all enemy pawns x-rayed