Skip to content

Commit e7362da

Browse files
snicoletmcostalba
authored andcommitted
Introduce penalty for weak (=unsupported) pawns.
We add a penalty for each pawn which is not protected by another pawn of the same color. Passed both short TC LLR: 2.96 (-2.94,2.94) [-1.50,4.50] Total: 12107 W: 2411 L: 2272 D: 7424 And long TC LLR: 2.96 (-2.94,2.94) [0.00,6.00] Total: 9204 W: 1605 L: 1458 D: 6141 bench: 7682173
1 parent 9e72e35 commit e7362da

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/pawns.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ namespace {
6060
// Bonus for file distance of the two outermost pawns
6161
const Score PawnsFileSpan = S(0, 15);
6262

63+
// Unsupported pawn penalty
64+
const Score UnsupportedPawnPenalty = S(20, 10);
65+
6366
// Weakness of our pawn shelter in front of the king indexed by [rank]
6467
const Value ShelterWeakness[RANK_NB] =
6568
{ V(100), V(0), V(27), V(73), V(92), V(101), V(101) };
@@ -86,10 +89,10 @@ namespace {
8689
const Square Right = (Us == WHITE ? DELTA_NE : DELTA_SW);
8790
const Square Left = (Us == WHITE ? DELTA_NW : DELTA_SE);
8891

89-
Bitboard b;
92+
Bitboard b, p;
9093
Square s;
9194
File f;
92-
bool passed, isolated, doubled, opposed, connected, backward, candidate;
95+
bool passed, isolated, doubled, opposed, connected, backward, candidate, unsupported;
9396
Score value = SCORE_ZERO;
9497
const Square* pl = pos.list<PAWN>(Us);
9598

@@ -113,16 +116,20 @@ namespace {
113116
// This file cannot be semi-open
114117
e->semiopenFiles[Us] &= ~(1 << f);
115118

119+
// Previous rank
120+
p = rank_bb(s - pawn_push(Us));
121+
116122
// Our rank plus previous one
117-
b = rank_bb(s) | rank_bb(s - pawn_push(Us));
123+
b = rank_bb(s) | p;
118124

119-
// Flag the pawn as passed, isolated, doubled or
120-
// connected (but not the backward one).
121-
connected = ourPawns & adjacent_files_bb(f) & b;
122-
isolated = !(ourPawns & adjacent_files_bb(f));
123-
doubled = ourPawns & forward_bb(Us, s);
124-
opposed = theirPawns & forward_bb(Us, s);
125-
passed = !(theirPawns & passed_pawn_mask(Us, s));
125+
// Flag the pawn as passed, isolated, doubled,
126+
// unsupported or connected (but not the backward one).
127+
connected = ourPawns & adjacent_files_bb(f) & b;
128+
unsupported = !(ourPawns & adjacent_files_bb(f) & p);
129+
isolated = !(ourPawns & adjacent_files_bb(f));
130+
doubled = ourPawns & forward_bb(Us, s);
131+
opposed = theirPawns & forward_bb(Us, s);
132+
passed = !(theirPawns & passed_pawn_mask(Us, s));
126133

127134
// Test for backward pawn.
128135
// If the pawn is passed, isolated, or connected it cannot be
@@ -166,6 +173,9 @@ namespace {
166173
if (isolated)
167174
value -= Isolated[opposed][f];
168175

176+
if (unsupported && !isolated)
177+
value -= UnsupportedPawnPenalty;
178+
169179
if (doubled)
170180
value -= Doubled[f];
171181

0 commit comments

Comments
 (0)