Skip to content

Commit

Permalink
Remove opposed flag for doubled pawns
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joergoster authored and mcostalba committed Nov 10, 2013
1 parent 1d18647 commit 4ef6b2c
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/pawns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,32 @@ namespace {
#define V Value
#define S(mg, eg) make_score(mg, eg)

// Doubled pawn penalty by opposed flag and file
const Score Doubled[2][FILE_NB] = {
{ S(13, 43), S(20, 48), S(23, 48), S(23, 48),
S(23, 48), S(23, 48), S(20, 48), S(13, 43) },
{ S(13, 43), S(20, 48), S(23, 48), S(23, 48),
S(23, 48), S(23, 48), S(20, 48), S(13, 43) }};
// Doubled pawn penalty by file
const Score Doubled[FILE_NB] = {
S(13, 43), S(20, 48), S(23, 48), S(23, 48),
S(23, 48), S(23, 48), S(20, 48), S(13, 43) };

// Isolated pawn penalty by opposed flag and file
const Score Isolated[2][FILE_NB] = {
{ S(37, 45), S(54, 52), S(60, 52), S(60, 52),
S(60, 52), S(60, 52), S(54, 52), S(37, 45) },
{ S(25, 30), S(36, 35), S(40, 35), S(40, 35),
S(40, 35), S(40, 35), S(36, 35), S(25, 30) }};
S(40, 35), S(40, 35), S(36, 35), S(25, 30) } };

// Backward pawn penalty by opposed flag and file
const Score Backward[2][FILE_NB] = {
{ S(30, 42), S(43, 46), S(49, 46), S(49, 46),
S(49, 46), S(49, 46), S(43, 46), S(30, 42) },
{ S(20, 28), S(29, 31), S(33, 31), S(33, 31),
S(33, 31), S(33, 31), S(29, 31), S(20, 28) }};
S(33, 31), S(33, 31), S(29, 31), S(20, 28) } };

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

// Candidate passed pawn bonus by rank
const Score CandidatePassed[RANK_NB] = {
S( 0, 0), S( 6, 13), S(6,13), S(14,29),
S(34,68), S(83,166), S(0, 0), S( 0, 0)
};
S(34,68), S(83,166), S(0, 0), S( 0, 0) };

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

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

#undef S
Expand Down Expand Up @@ -148,7 +145,7 @@ namespace {

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

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

if (doubled)
value -= Doubled[opposed][f];
value -= Doubled[f];

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

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

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

Expand Down

0 comments on commit 4ef6b2c

Please sign in to comment.