Skip to content

Commit 4ef6b2c

Browse files
joergostermcostalba
authored andcommitted
Remove opposed flag for doubled pawns
Actually, it is not used, as both arrays have the same values. Some local tests in either direction showed no improvement. Also some minor corrections in the comments. No functional change.
1 parent 1d18647 commit 4ef6b2c

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/pawns.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,32 @@ namespace {
3030
#define V Value
3131
#define S(mg, eg) make_score(mg, eg)
3232

33-
// Doubled pawn penalty by opposed flag and file
34-
const Score Doubled[2][FILE_NB] = {
35-
{ S(13, 43), S(20, 48), S(23, 48), S(23, 48),
36-
S(23, 48), S(23, 48), S(20, 48), S(13, 43) },
37-
{ S(13, 43), S(20, 48), S(23, 48), S(23, 48),
38-
S(23, 48), S(23, 48), S(20, 48), S(13, 43) }};
33+
// Doubled pawn penalty by file
34+
const Score Doubled[FILE_NB] = {
35+
S(13, 43), S(20, 48), S(23, 48), S(23, 48),
36+
S(23, 48), S(23, 48), S(20, 48), S(13, 43) };
3937

4038
// Isolated pawn penalty by opposed flag and file
4139
const Score Isolated[2][FILE_NB] = {
4240
{ S(37, 45), S(54, 52), S(60, 52), S(60, 52),
4341
S(60, 52), S(60, 52), S(54, 52), S(37, 45) },
4442
{ S(25, 30), S(36, 35), S(40, 35), S(40, 35),
45-
S(40, 35), S(40, 35), S(36, 35), S(25, 30) }};
43+
S(40, 35), S(40, 35), S(36, 35), S(25, 30) } };
4644

4745
// Backward pawn penalty by opposed flag and file
4846
const Score Backward[2][FILE_NB] = {
4947
{ S(30, 42), S(43, 46), S(49, 46), S(49, 46),
5048
S(49, 46), S(49, 46), S(43, 46), S(30, 42) },
5149
{ S(20, 28), S(29, 31), S(33, 31), S(33, 31),
52-
S(33, 31), S(33, 31), S(29, 31), S(20, 28) }};
50+
S(33, 31), S(33, 31), S(29, 31), S(20, 28) } };
5351

5452
// Pawn chain membership bonus by file and rank (initialized by formula)
5553
Score ChainMember[FILE_NB][RANK_NB];
5654

5755
// Candidate passed pawn bonus by rank
5856
const Score CandidatePassed[RANK_NB] = {
5957
S( 0, 0), S( 6, 13), S(6,13), S(14,29),
60-
S(34,68), S(83,166), S(0, 0), S( 0, 0)
61-
};
58+
S(34,68), S(83,166), S(0, 0), S( 0, 0) };
6259

6360
// Weakness of our pawn shelter in front of the king indexed by [rank]
6461
const Value ShelterWeakness[RANK_NB] =
@@ -69,10 +66,10 @@ namespace {
6966
const Value StormDanger[3][RANK_NB] = {
7067
{ V( 0), V(64), V(128), V(51), V(26) },
7168
{ V(26), V(32), V( 96), V(38), V(20) },
72-
{ V( 0), V( 0), V( 64), V(25), V(13) }};
69+
{ V( 0), V( 0), V( 64), V(25), V(13) } };
7370

7471
// Max bonus for king safety. Corresponds to start position with all the pawns
75-
// in front of the king and no enemy pawn on the horizont.
72+
// in front of the king and no enemy pawn on the horizon.
7673
const Value MaxSafetyBonus = V(263);
7774

7875
#undef S
@@ -148,7 +145,7 @@ namespace {
148145

149146
assert(opposed | passed | (pawn_attack_span(Us, s) & theirPawns));
150147

151-
// A not passed pawn is a candidate to become passed if it is free to
148+
// A not passed pawn is a candidate to become passed, if it is free to
152149
// advance and if the number of friendly pawns beside or behind this
153150
// pawn on adjacent files is higher or equal than the number of
154151
// enemy pawns in the forward direction on the adjacent files.
@@ -167,7 +164,7 @@ namespace {
167164
value -= Isolated[opposed][f];
168165

169166
if (doubled)
170-
value -= Doubled[opposed][f];
167+
value -= Doubled[f];
171168

172169
if (backward)
173170
value -= Backward[opposed][f];
@@ -274,7 +271,7 @@ Score Entry::update_safety(const Position& pos, Square ksq) {
274271

275272
Value bonus = shelter_storm<Us>(pos, ksq);
276273

277-
// If we can castle use the bonus after the castle if is bigger
274+
// If we can castle use the bonus after the castle if it is bigger
278275
if (pos.can_castle(make_castle_right(Us, KING_SIDE)))
279276
bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_G1)));
280277

0 commit comments

Comments
 (0)