1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-02 17:49:35 +00:00

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
This commit is contained in:
Gary Linscott 2013-12-18 14:00:01 -05:00 committed by Marco Costalba
parent f196c1bad8
commit 26689d8c2a

View file

@ -150,11 +150,8 @@ namespace {
// Threat[attacking][attacked] contains bonuses according to which piece // Threat[attacking][attacked] contains bonuses according to which piece
// type attacks which one. // type attacks which one.
const Score Threat[][PIECE_TYPE_NB] = { const Score Threat[][PIECE_TYPE_NB] = {
{}, {}, { S(0, 0), S( 7, 39), S(24, 49), S(24, 49), S(41,100), S(41,100) }, // Minor
{ S(0, 0), S( 7, 39), S( 0, 0), S(24, 49), S(41,100), S(41,100) }, // KNIGHT { S(0, 0), S(15, 39), S(15, 45), S(15, 45), S(15, 45), S(24, 49) }, // Major
{ 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
}; };
// ThreatenedByPawn[PieceType] contains a penalty according to which piece // ThreatenedByPawn[PieceType] contains a penalty according to which piece
@ -762,17 +759,16 @@ Value do_evaluate(const Position& pos) {
& ~ei.attackedBy[Them][PAWN] & ~ei.attackedBy[Them][PAWN]
& ei.attackedBy[Us][ALL_PIECES]; & ei.attackedBy[Us][ALL_PIECES];
// Add bonus according to type of attacked enemy piece and to the // Add a bonus according if the attacking pieces are minor or major
// type of attacking piece, from knights to queens. Kings are not
// considered because they are already handled in king evaluation.
if (weakEnemies) if (weakEnemies)
for (PieceType pt1 = KNIGHT; pt1 < KING; ++pt1)
{ {
b = ei.attackedBy[Us][pt1] & weakEnemies; b = weakEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
if (b) if (b)
for (PieceType pt2 = PAWN; pt2 < KING; ++pt2) score += Threat[0][type_of(pos.piece_on(lsb(b)))];
if (b & pos.pieces(pt2))
score += Threat[pt1][pt2]; b = weakEnemies & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]);
if (b)
score += Threat[1][type_of(pos.piece_on(lsb(b)))];
} }
if (Trace) if (Trace)