template<Tracing T> template<Color Us>
Score Evaluation<T>::threats() const {
- const Color Them = (Us == WHITE ? BLACK : WHITE);
- const Direction Up = (Us == WHITE ? NORTH : SOUTH);
- const Direction Left = (Us == WHITE ? NORTH_WEST : SOUTH_EAST);
- const Direction Right = (Us == WHITE ? NORTH_EAST : SOUTH_WEST);
- const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
+ const Color Them = (Us == WHITE ? BLACK : WHITE);
+ const Direction Up = (Us == WHITE ? NORTH : SOUTH);
+ const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
Bitboard b, weak, defended, nonPawnEnemies, stronglyProtected, safeThreats;
Score score = SCORE_ZERO;
b = pos.pieces(Us, PAWN)
& (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]);
- safeThreats = (shift<Right>(b) | shift<Left>(b)) & weak;
+ safeThreats = pawn_attacks_bb<Us>(b) & weak;
score += ThreatBySafePawn * popcount(safeThreats);
}
& (attackedBy[Us][ALL_PIECES] | ~attackedBy[Them][ALL_PIECES]);
// Bonus for safe pawn threats on the next move
- b = (shift<Left>(b) | shift<Right>(b))
+ b = pawn_attacks_bb<Us>(b)
& pos.pieces(Them)
& ~attackedBy[Us][PAWN];
&& (pos.pieces(PAWN) & KingSide);
// Compute the initiative bonus for the attacking side
- int initiative = 8 * outflanking
+ int complexity = 8 * outflanking
+ 8 * pe->pawn_asymmetry()
+ 12 * pos.count<PAWN>()
+ 16 * pawnsOnBothFlanks
// Now apply the bonus: note that we find the attacking side by extracting
// the sign of the endgame value, and that we carefully cap the bonus so
// that the endgame score will never change sign after the bonus.
- int v = ((eg > 0) - (eg < 0)) * std::max(initiative, -abs(eg));
+ int v = ((eg > 0) - (eg < 0)) * std::max(complexity, -abs(eg));
if (T)
Trace::add(INITIATIVE, make_score(0, v));