Move new code in the if (defended | weak) {} section.
No functional change
// Non-pawn enemies
nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN);
// Non-pawn enemies
nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN);
- // Our safe or protected pawns
- b = pos.pieces(Us, PAWN)
- & (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]);
-
- safeThreats = pawn_attacks_bb<Us>(b) & nonPawnEnemies;
- score += ThreatBySafePawn * popcount(safeThreats);
-
// Squares strongly protected by the enemy, either because they defend the
// square with a pawn, or because they defend the square twice and we don't.
stronglyProtected = attackedBy[Them][PAWN]
// Squares strongly protected by the enemy, either because they defend the
// square with a pawn, or because they defend the square twice and we don't.
stronglyProtected = attackedBy[Them][PAWN]
score += ThreatByRank * (int)relative_rank(Them, s);
}
score += ThreatByRank * (int)relative_rank(Them, s);
}
- score += Hanging * popcount(weak & ~attackedBy[Them][ALL_PIECES]);
-
b = weak & attackedBy[Us][KING];
if (b)
score += ThreatByKing[more_than_one(b)];
b = weak & attackedBy[Us][KING];
if (b)
score += ThreatByKing[more_than_one(b)];
+
+ score += Hanging * popcount(weak & ~attackedBy[Them][ALL_PIECES]);
+
+ // 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);
}
// Bonus for enemy unopposed weak pawns
if (pos.pieces(Us, ROOK, QUEEN))
score += WeakUnopposedPawn * pe->weak_unopposed(Them);
}
// Bonus for enemy unopposed weak pawns
if (pos.pieces(Us, ROOK, QUEEN))
score += WeakUnopposedPawn * pe->weak_unopposed(Them);
+ // Our safe or protected pawns
+ b = pos.pieces(Us, PAWN)
+ & (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]);
+
+ safeThreats = pawn_attacks_bb<Us>(b) & nonPawnEnemies;
+ score += ThreatBySafePawn * popcount(safeThreats);
+
// Find squares where our pawns can push on the next move
b = shift<Up>(pos.pieces(Us, PAWN)) & ~pos.pieces();
b |= shift<Up>(b & TRank3BB) & ~pos.pieces();
// Find squares where our pawns can push on the next move
b = shift<Up>(pos.pieces(Us, PAWN)) & ~pos.pieces();
b |= shift<Up>(b & TRank3BB) & ~pos.pieces();
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);
-
if (T)
Trace::add(THREAT, Us, score);
if (T)
Trace::add(THREAT, Us, score);