X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=7fb0e26ae9ec90a5504eb5215de3514494a4fa24;hp=d2aab71df68c393c5e0323d87514efdaf523aa64;hb=9d219c07e46bd527f4d9ff4d5b273102b59521c3;hpb=fc0a1f37cf2029af3d35221423da7ac512afbf88 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index d2aab71d..7fb0e26a 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -89,7 +89,7 @@ namespace { constexpr Value SpaceThreshold = Value(12222); // KingAttackWeights[PieceType] contains king attack weights by piece type - constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 78, 56, 45, 11 }; + constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 77, 55, 44, 10 }; // Penalties for enemy's safe checks constexpr int QueenSafeCheck = 780; @@ -281,7 +281,7 @@ namespace { else if (file_of(pos.square(Us)) == FILE_A) kingRing[Us] |= shift(kingRing[Us]); - kingAttackersCount[Them] = popcount(attackedBy[Us][KING] & pe->pawn_attacks(Them)); + kingAttackersCount[Them] = popcount(kingRing[Us] & pe->pawn_attacks(Them)); kingAttacksCount[Them] = kingAttackersWeight[Them] = 0; } else @@ -420,7 +420,7 @@ namespace { : AllSquares ^ Rank1BB ^ Rank2BB ^ Rank3BB); const Square ksq = pos.square(Us); - Bitboard weak, b, b1, b2, safe, unsafeChecks, pinned; + Bitboard weak, b, b1, b2, safe, unsafeChecks; // King shelter and enemy pawns storm Score score = pe->king_safety(pos, ksq); @@ -472,12 +472,11 @@ namespace { // Unsafe or occupied checking squares will also be considered, as long as // the square is in the attacker's mobility area. unsafeChecks &= mobilityArea[Them]; - pinned = pos.blockers_for_king(Us) & pos.pieces(Us); kingDanger += kingAttackersCount[Them] * kingAttackersWeight[Them] + 102 * kingAttacksCount[Them] + 191 * popcount(kingRing[Us] & weak) - + 143 * popcount(pinned | unsafeChecks) + + 143 * popcount(pos.blockers_for_king(Us) | unsafeChecks) - 848 * !pos.count(Them) - 9 * mg_value(score) / 8 + 40; @@ -802,20 +801,13 @@ namespace { // If scale is not already specific, scale down the endgame via general heuristics if (sf == SCALE_FACTOR_NORMAL) { - if (pos.opposite_bishops()) - { + if ( pos.opposite_bishops() + && pos.non_pawn_material(WHITE) == BishopValueMg + && pos.non_pawn_material(BLACK) == BishopValueMg) // Endgame with opposite-colored bishops and no other pieces is almost a draw - if ( pos.non_pawn_material(WHITE) == BishopValueMg - && pos.non_pawn_material(BLACK) == BishopValueMg) - sf = 31; - - // Endgame with opposite-colored bishops, but also other pieces. Still - // a bit drawish, but not as drawish as with only the two bishops. - else - sf = 46; - } + sf = 31; else - sf = std::min(40 + 7 * pos.count(strongSide), sf); + sf = std::min(40 + (pos.opposite_bishops()? 2 : 7) * pos.count(strongSide), sf); } return ScaleFactor(sf);