From: Gary Linscott Date: Wed, 18 Dec 2013 19:00:01 +0000 (-0500) Subject: Faster and simplified threat eval X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=26689d8c2ae506e4da1a5654fcfdfe04886c3692 Faster and simplified threat eval Add a bonus according if the attacking pieces are minor or major. Passed both short TC LLR: 2.96 (-2.94,2.94) [-1.50,4.50] Total: 13142 W: 2625 L: 2483 D: 8034 And long TC LLR: 2.95 (-2.94,2.94) [0.00,6.00] Total: 18059 W: 3031 L: 2844 D: 12184 bench: 7425809 --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 7d57dddb..1ee727da 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -150,11 +150,8 @@ namespace { // Threat[attacking][attacked] contains bonuses according to which piece // type attacks which one. const Score Threat[][PIECE_TYPE_NB] = { - {}, {}, - { S(0, 0), S( 7, 39), S( 0, 0), S(24, 49), S(41,100), S(41,100) }, // KNIGHT - { S(0, 0), S( 7, 39), S(24, 49), S( 0, 0), S(41,100), S(41,100) }, // BISHOP - { S(0, 0), S( 0, 22), S(15, 49), S(15, 49), S( 0, 0), S(24, 49) }, // ROOK - { S(0, 0), S(15, 39), S(15, 39), S(15, 39), S(15, 39), S( 0, 0) } // QUEEN + { S(0, 0), S( 7, 39), S(24, 49), S(24, 49), S(41,100), S(41,100) }, // Minor + { S(0, 0), S(15, 39), S(15, 45), S(15, 45), S(15, 45), S(24, 49) }, // Major }; // ThreatenedByPawn[PieceType] contains a penalty according to which piece @@ -762,18 +759,17 @@ Value do_evaluate(const Position& pos) { & ~ei.attackedBy[Them][PAWN] & ei.attackedBy[Us][ALL_PIECES]; - // Add bonus according to type of attacked enemy piece and to the - // type of attacking piece, from knights to queens. Kings are not - // considered because they are already handled in king evaluation. + // Add a bonus according if the attacking pieces are minor or major if (weakEnemies) - for (PieceType pt1 = KNIGHT; pt1 < KING; ++pt1) - { - b = ei.attackedBy[Us][pt1] & weakEnemies; - if (b) - for (PieceType pt2 = PAWN; pt2 < KING; ++pt2) - if (b & pos.pieces(pt2)) - score += Threat[pt1][pt2]; - } + { + b = weakEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]); + if (b) + score += Threat[0][type_of(pos.piece_on(lsb(b)))]; + + b = weakEnemies & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]); + if (b) + score += Threat[1][type_of(pos.piece_on(lsb(b)))]; + } if (Trace) Tracing::scores[Us][THREAT] = score;