X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=a0e22516002acbd0b2aebf8eb66e50918f6dec25;hp=82bf950c032592afacb9111df4ded445207915f4;hb=766fb9c67da48c696e9444a3a46c531786172256;hpb=896bd917f8e0dc5899b498fc3b62d3ee5e8fd9fe diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 82bf950c..a0e22516 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -150,23 +150,24 @@ namespace { S(0, 0), S(0, 0), S(80, 119), S(80, 119), S(117, 199), S(127, 218) }; - // Hanging contains a bonus for each enemy hanging piece - const Score Hanging = S(23, 20); - - #undef S - - const Score RookOnPawn = make_score(10, 28); - const Score RookOpenFile = make_score(43, 21); - const Score RookSemiopenFile = make_score(19, 10); - const Score BishopPawns = make_score( 8, 12); - const Score MinorBehindPawn = make_score(16, 0); - const Score TrappedRook = make_score(92, 0); - const Score Unstoppable = make_score( 0, 20); + // Assorted bonuses and penalties used by evaluation + const Score KingOnPawnOne = S(0 , 64); + const Score KingOnPawnMany = S(0 ,128); + const Score RookOnPawn = S(10, 28); + const Score RookOpenFile = S(43, 21); + const Score RookSemiOpenFile = S(19, 10); + const Score BishopPawns = S( 8, 12); + const Score MinorBehindPawn = S(16, 0); + const Score TrappedRook = S(92, 0); + const Score Unstoppable = S( 0, 20); + const Score Hanging = S(23, 20); // 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 // happen in Chess960 games. - const Score TrappedBishopA1H1 = make_score(50, 50); + const Score TrappedBishopA1H1 = S(50, 50); + + #undef S // SpaceMask[Color] contains the area of the board which is considered // by the space evaluation. In the middlegame, each side is given a bonus @@ -255,7 +256,7 @@ namespace { bonus += bonus / 2; } - return make_score(bonus, bonus); + return make_score(bonus * 2, bonus / 2); } @@ -338,7 +339,7 @@ namespace { // Give a bonus for a rook on a open or semi-open file if (ei.pi->semiopen_file(Us, file_of(s))) - score += ei.pi->semiopen_file(Them, file_of(s)) ? RookOpenFile : RookSemiopenFile; + score += ei.pi->semiopen_file(Them, file_of(s)) ? RookOpenFile : RookSemiOpenFile; if (mob > 3 || ei.pi->semiopen_file(Us, file_of(s))) continue; @@ -498,6 +499,7 @@ namespace { Bitboard b, weakEnemies, protectedEnemies; Score score = SCORE_ZERO; + enum { Minor, Major }; // Protected enemies protectedEnemies = (pos.pieces(Them) ^ pos.pieces(Them,PAWN)) @@ -505,7 +507,7 @@ namespace { & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]); if(protectedEnemies) - score += Threat[0][type_of(pos.piece_on(lsb(protectedEnemies)))]; + score += Threat[Minor][type_of(pos.piece_on(lsb(protectedEnemies)))]; // Enemies not defended by a pawn and under our attack weakEnemies = pos.pieces(Them) @@ -517,15 +519,19 @@ namespace { { b = weakEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]); if (b) - score += Threat[0][type_of(pos.piece_on(lsb(b)))]; + score += Threat[Minor][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)))]; + score += Threat[Major][type_of(pos.piece_on(lsb(b)))]; b = weakEnemies & ~ei.attackedBy[Them][ALL_PIECES]; if (b) score += more_than_one(b) ? Hanging * popcount(b) : Hanging; + + b = weakEnemies & pos.pieces(Them, PAWN) & ei.attackedBy[Us][KING]; + if (b) + score += more_than_one(b) ? KingOnPawnMany : KingOnPawnOne; } if (Trace)