1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Tidy up on Overload

Move new code in the if (defended | weak) {} section.

No functional change
This commit is contained in:
Alain SAVARD 2018-04-18 19:44:22 +02:00 committed by Stéphane Nicolet
parent 0143c6f0c2
commit 66af80972a

View file

@ -524,13 +524,6 @@ namespace {
// 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]
@ -563,17 +556,30 @@ namespace {
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)];
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);
// 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();
@ -609,12 +615,6 @@ namespace {
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);