mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Add bonus for pawn attack threats
Latent pawn attacks: Add a bonus to safe pawn pushes which attacks an enemy piece. Based on an idea of Lyudmil Tsvetkov. STC: LLR: 2.95 (-2.94,2.94) [-1.50,4.50] Total: 7925 W: 1666 L: 1537 D: 4722 LTC: LLR: 2.95 (-2.94,2.94) [0.00,6.00] Total: 40109 W: 6841 L: 6546 D: 26722 Bench: 7696257 Resolves #240
This commit is contained in:
parent
f4136c5434
commit
18b0809639
1 changed files with 22 additions and 1 deletions
|
@ -162,6 +162,7 @@ namespace {
|
||||||
const Score TrappedRook = S(92, 0);
|
const Score TrappedRook = S(92, 0);
|
||||||
const Score Unstoppable = S( 0, 20);
|
const Score Unstoppable = S( 0, 20);
|
||||||
const Score Hanging = S(31, 26);
|
const Score Hanging = S(31, 26);
|
||||||
|
const Score PawnAttackThreat = S(20, 20);
|
||||||
|
|
||||||
// Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
|
// Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
|
||||||
// a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
|
// a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
|
||||||
|
@ -492,7 +493,12 @@ namespace {
|
||||||
template<Color Us, bool Trace>
|
template<Color Us, bool Trace>
|
||||||
Score evaluate_threats(const Position& pos, const EvalInfo& ei) {
|
Score evaluate_threats(const Position& pos, const EvalInfo& ei) {
|
||||||
|
|
||||||
const Color Them = (Us == WHITE ? BLACK : WHITE);
|
const Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||||
|
const Square Up = (Us == WHITE ? DELTA_N : DELTA_S);
|
||||||
|
const Square Left = (Us == WHITE ? DELTA_NW : DELTA_SE);
|
||||||
|
const Square Right = (Us == WHITE ? DELTA_NE : DELTA_SW);
|
||||||
|
const Bitboard TRank2BB = (Us == WHITE ? Rank2BB : Rank7BB);
|
||||||
|
const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
|
||||||
|
|
||||||
enum { Defended, Weak };
|
enum { Defended, Weak };
|
||||||
enum { Minor, Major };
|
enum { Minor, Major };
|
||||||
|
@ -541,6 +547,21 @@ namespace {
|
||||||
score += more_than_one(b) ? KingOnMany : KingOnOne;
|
score += more_than_one(b) ? KingOnMany : KingOnOne;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add bonus for safe pawn pushes which attacks an enemy piece
|
||||||
|
b = pos.pieces(Us, PAWN) & ~TRank7BB;
|
||||||
|
b = shift_bb<Up>(b | (shift_bb<Up>(b & TRank2BB) & ~pos.pieces()));
|
||||||
|
|
||||||
|
b &= ~pos.pieces()
|
||||||
|
& ~ei.attackedBy[Them][PAWN]
|
||||||
|
& (ei.attackedBy[Us][PAWN] | ~ei.attackedBy[Them][ALL_PIECES]);
|
||||||
|
|
||||||
|
b = (shift_bb<Left>(b) | shift_bb<Right>(b))
|
||||||
|
& pos.pieces(Them)
|
||||||
|
& ~ei.attackedBy[Us][PAWN];
|
||||||
|
|
||||||
|
if(b)
|
||||||
|
score += popcount<Max15>(b) * PawnAttackThreat;
|
||||||
|
|
||||||
if (Trace)
|
if (Trace)
|
||||||
Tracing::write(Tracing::THREAT, Us, score);
|
Tracing::write(Tracing::THREAT, Us, score);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue