@@ -32,9 +32,9 @@ namespace {
3232 #define S (mg, eg ) make_score(mg, eg)
3333
3434 // Pawn penalties
35- constexpr Score Backward = S( 9 , 24 );
36- constexpr Score Doubled = S(11 , 56 );
37- constexpr Score Isolated = S( 5 , 15 );
35+ constexpr Score Backward = S( 9 , 24 );
36+ constexpr Score Doubled = S(11 , 56 );
37+ constexpr Score Isolated = S( 5 , 15 );
3838 constexpr Score WeakUnopposed = S( 13 , 27 );
3939 constexpr Score Attacked2Unsupported = S( 0 , 20 );
4040
@@ -108,17 +108,18 @@ namespace {
108108 phalanx = neighbours & rank_bb (s);
109109 support = neighbours & rank_bb (s - Up);
110110
111- // A pawn is backward when it is behind all pawns of the same color
112- // on the adjacent files and cannot be safely advanced.
113- backward = !(ourPawns & pawn_attack_span (Them, s + Up))
111+ // A pawn is backward when it is behind all pawns of the same color on
112+ // the adjacent files and cannot safely advance. Phalanx and isolated
113+ // pawns will be excluded when the pawn is scored.
114+ backward = !(neighbours & forward_ranks_bb (Them, s))
114115 && (stoppers & (leverPush | (s + Up)));
115116
116117 // Passed pawns will be properly scored in evaluation because we need
117118 // full attack info to evaluate them. Include also not passed pawns
118119 // which could become passed after one or two pawn pushes when are
119120 // not attacked more times than defended.
120- if ( !(stoppers ^ lever) ||
121- (!(stoppers ^ leverPush) && popcount (phalanx) >= popcount (leverPush)))
121+ if ( !(stoppers ^ lever) ||
122+ (!(stoppers ^ leverPush) && popcount (phalanx) >= popcount (leverPush)))
122123 e->passedPawns [Us] |= s;
123124
124125 else if (stoppers == square_bb (s + Up) && r >= RANK_5)
@@ -137,6 +138,7 @@ namespace {
137138
138139 score += make_score (v, v * (r - 2 ) / 4 );
139140 }
141+
140142 else if (!neighbours)
141143 score -= Isolated + WeakUnopposed * int (!opposed);
142144
0 commit comments