constexpr Score KnightOnQueen = S( 21, 11);
constexpr Score LongDiagonalBishop = S( 22, 0);
constexpr Score MinorBehindPawn = S( 16, 0);
constexpr Score KnightOnQueen = S( 21, 11);
constexpr Score LongDiagonalBishop = S( 22, 0);
constexpr Score MinorBehindPawn = S( 16, 0);
constexpr Score PawnlessFlank = S( 20, 80);
constexpr Score RookOnPawn = S( 8, 24);
constexpr Score SliderOnQueen = S( 42, 21);
constexpr Score PawnlessFlank = S( 20, 80);
constexpr Score RookOnPawn = S( 8, 24);
constexpr Score SliderOnQueen = S( 42, 21);
Bitboard b, weak, defended, nonPawnEnemies, stronglyProtected, safeThreats;
Score score = SCORE_ZERO;
Bitboard b, weak, defended, nonPawnEnemies, stronglyProtected, safeThreats;
Score score = SCORE_ZERO;
nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN);
// Our safe or protected pawns
nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN);
// Our safe or protected pawns
b = (pos.pieces(Us) ^ pos.pieces(Us, PAWN, KING)) & attackedBy[Us][ALL_PIECES];
score += Connectivity * popcount(b);
b = (pos.pieces(Us) ^ pos.pieces(Us, PAWN, KING)) & attackedBy[Us][ALL_PIECES];
score += Connectivity * popcount(b);
+ // Bonus for overload (non-pawn enemies attacked and defended exactly once)
+ b = nonPawnEnemies
+ & attackedBy[Us][ALL_PIECES] & ~attackedBy2[Us]
+ & attackedBy[Them][ALL_PIECES] & ~attackedBy2[Them];
+ score += Overload * popcount(b);
+
// pawn, or if it is undefended and attacked by an enemy piece.
Bitboard safe = SpaceMask
& ~pos.pieces(Us, PAWN)
// pawn, or if it is undefended and attacked by an enemy piece.
Bitboard safe = SpaceMask
& ~pos.pieces(Us, PAWN)
// Find all squares which are at most three squares behind some friendly pawn
Bitboard behind = pos.pieces(Us, PAWN);
// Find all squares which are at most three squares behind some friendly pawn
Bitboard behind = pos.pieces(Us, PAWN);