// Assorted bonuses and penalties
constexpr Score BishopPawns = S( 3, 7);
+ constexpr Score BishopXRayPawns = S( 4, 5);
constexpr Score CorneredBishop = S( 50, 50);
constexpr Score FlankAttacks = S( 8, 0);
constexpr Score Hanging = S( 69, 36);
score -= BishopPawns * pos.pawns_on_same_color_squares(Us, s)
* (!(attackedBy[Us][PAWN] & s) + popcount(blocked & CenterFiles));
+ // Penalty for all enemy pawns x-rayed
+ score -= BishopXRayPawns * popcount(PseudoAttacks[BISHOP][s] & pos.pieces(Them, PAWN));
+
// Bonus for bishop on a long diagonal which can "see" both center squares
if (more_than_one(attacks_bb<BISHOP>(s, pos.pieces(PAWN)) & Center))
score += LongDiagonalBishop;
return std::min(distance(pos.square<KING>(c), s), 5);
};
- Bitboard b, bb, squaresToQueen, unsafeSquares, candidatePassers, leverable;
+ Bitboard b, bb, squaresToQueen, unsafeSquares, blockedPassers, helpers;
Score score = SCORE_ZERO;
b = pe->passed_pawns(Us);
- candidatePassers = b & shift<Down>(pos.pieces(Them, PAWN));
- if (candidatePassers)
+ blockedPassers = b & shift<Down>(pos.pieces(Them, PAWN));
+ if (blockedPassers)
{
- // Can we lever the blocker of a candidate passer?
- leverable = shift<Up>(pos.pieces(Us, PAWN))
- & ~pos.pieces(Them)
- & (~attackedBy2[Them] | attackedBy[Us][ALL_PIECES])
- & (~(attackedBy[Them][KNIGHT] | attackedBy[Them][BISHOP])
- | (attackedBy[Us ][KNIGHT] | attackedBy[Us ][BISHOP]));
-
- // Remove candidate otherwise
- b &= ~candidatePassers
- | shift<WEST>(leverable)
- | shift<EAST>(leverable);
+ helpers = shift<Up>(pos.pieces(Us, PAWN))
+ & ~pos.pieces(Them)
+ & (~attackedBy2[Them] | attackedBy[Us][ALL_PIECES]);
+
+ // Remove blocked candidate passers that don't have help to pass
+ b &= ~blockedPassers
+ | shift<WEST>(helpers)
+ | shift<EAST>(helpers);
}
while (b)
// Compute the initiative bonus for the attacking side
int complexity = 9 * pe->passed_count()
- + 11 * pos.count<PAWN>()
+ + 12 * pos.count<PAWN>()
+ 9 * outflanking
+ 21 * pawnsOnBothFlanks
+ 24 * infiltration
+ 51 * !pos.non_pawn_material()
- 43 * almostUnwinnable
+ - 2 * pos.rule50_count()
-110 ;
Value mg = mg_value(score);
}
else
sf = std::min(sf, 36 + 7 * pos.count<PAWN>(strongSide));
-
- sf = std::max(0, sf - (pos.rule50_count() - 12) / 4);
}
return ScaleFactor(sf);
Trace::add(TOTAL, score);
}
- return (pos.side_to_move() == WHITE ? v : -v) + Tempo; // Side to move point of view
+ // Side to move point of view
+ return (pos.side_to_move() == WHITE ? v : -v) + Tempo;
}
} // namespace