Skip to content

Commit

Permalink
Give a reduced bonus for threats by hanging pawns
Browse files Browse the repository at this point in the history
Passed STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 105539 W: 20389 L: 20001 D: 65149

and LTC:
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 9629 W: 1577 L: 1432 D: 6620

Bench: 7658627

Resolves #317
  • Loading branch information
ajithcj authored and glinscott committed Mar 28, 2015
1 parent 1d5eaba commit 6350027
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/evaluate.cpp
Expand Up @@ -158,6 +158,8 @@ namespace {
S(0, 0), S(0, 0), S(107, 138), S(84, 122), S(114, 203), S(121, 217)
};

const Score ThreatenedByHangingPawn = S(40, 60);

// Assorted bonuses and penalties used by evaluation
const Score KingOnOne = S( 2, 58);
const Score KingOnMany = S( 6,125);
Expand Down Expand Up @@ -305,11 +307,6 @@ namespace {

mobility[Us] += MobilityBonus[Pt][mob];

// Decrease score if we are attacked by an enemy pawn. The remaining part
// of threat evaluation must be done later when we have full attack info.
if (ei.attackedBy[Them][PAWN] & s)
score -= ThreatenedByPawn[Pt];

if (Pt == BISHOP || Pt == KNIGHT)
{
// Bonus for outpost square
Expand Down Expand Up @@ -501,9 +498,26 @@ namespace {
enum { Defended, Weak };
enum { Minor, Major };

Bitboard b, weak, defended;
Bitboard b, weak, defended, safe_pawns, safe_pawn_threats, unsafe_pawn_threats;
Score score = SCORE_ZERO;

// Pawn Threats
b = ei.attackedBy[Us][PAWN] & (pos.pieces(Them) ^ pos.pieces(Them, PAWN));
if(b)
{
safe_pawns = pos.pieces(Us, PAWN) & (~ei.attackedBy[Them][ALL_PIECES] | ei.attackedBy[Us][ALL_PIECES]);
safe_pawn_threats = (shift_bb<Right>(safe_pawns) | shift_bb<Left>(safe_pawns)) & (pos.pieces(Them) ^ pos.pieces(Them, PAWN));
unsafe_pawn_threats = b ^ safe_pawn_threats;
// Unsafe pawn threats
if(unsafe_pawn_threats)
score += ThreatenedByHangingPawn;

// Evaluate safe pawn threats
while(safe_pawn_threats)
score += ThreatenedByPawn[type_of(pos.piece_on(pop_lsb(&safe_pawn_threats)))];

}

// Non-pawn enemies defended by a pawn
defended = (pos.pieces(Them) ^ pos.pieces(Them, PAWN)) & ei.attackedBy[Them][PAWN];

Expand Down

0 comments on commit 6350027

Please sign in to comment.