X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=c98a83fc81a777806b111d80200946eaeb271da7;hb=213166ba225bcefbbe7dbecdacfd726dfb6c34f9;hp=1505bf67facd53bcd028eac73d795b25d49ee8af;hpb=66af80972a6ae085f6348d38ca5e4eb08734437d;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 1505bf67..c98a83fc 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -258,9 +258,9 @@ namespace { // Find our pawns that are blocked or on the first two ranks Bitboard b = pos.pieces(Us, PAWN) & (shift(pos.pieces()) | LowRanks); - // Squares occupied by those pawns, by our king, or controlled by enemy pawns + // Squares occupied by those pawns, by our king or queen, or controlled by enemy pawns // are excluded from the mobility area. - mobilityArea[Us] = ~(b | pos.square(Us) | pe->pawn_attacks(Them)); + mobilityArea[Us] = ~(b | pos.pieces(Us, KING, QUEEN) | pe->pawn_attacks(Them)); // Initialise attackedBy bitboards for kings and pawns attackedBy[Us][KING] = pos.attacks_from(pos.square(Us)); @@ -301,7 +301,6 @@ namespace { Bitboard b, bb; Square s; Score score = SCORE_ZERO; - int mob; attackedBy[Us][Pt] = 0; @@ -326,8 +325,7 @@ namespace { kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]); } - mob = (Pt == KNIGHT || Pt == BISHOP) ? popcount(b & mobilityArea[Us] & ~pos.pieces(Us, QUEEN)) - : popcount(b & mobilityArea[Us]); + int mob = popcount(b & mobilityArea[Us]); mobility[Us] += MobilityBonus[Pt - 2][mob]; @@ -700,7 +698,7 @@ namespace { } // w != 0 // Scale down bonus for candidate passers which need more than one - // pawn push to become passed or have a pawn in front of them. + // pawn push to become passed, or have a pawn in front of them. if ( !pos.pawn_passed(Us, s + Up) || (pos.pieces(PAWN) & forward_file_bb(Us, s))) bonus = bonus / 2; @@ -733,9 +731,7 @@ namespace { if (pos.non_pawn_material() < SpaceThreshold) return SCORE_ZERO; - // Find the safe squares for our pieces inside the area defined by - // SpaceMask. A square is unsafe if it is attacked by an enemy - // pawn, or if it is undefended and attacked by an enemy piece. + // Find the available squares for our pieces inside the area defined by SpaceMask Bitboard safe = SpaceMask & ~pos.pieces(Us, PAWN) & ~attackedBy[Them][PAWN]; @@ -798,9 +794,8 @@ namespace { Color strongSide = eg > VALUE_DRAW ? WHITE : BLACK; int sf = me->scale_factor(pos, strongSide); - // If we don't already have an unusual scale factor, check for certain - // types of endgames, and use a lower scale for those. - if (sf == SCALE_FACTOR_NORMAL || sf == SCALE_FACTOR_ONEPAWN) + // If scale is not already specific, scale down the endgame via general heuristics + if (sf == SCALE_FACTOR_NORMAL) { if (pos.opposite_bishops()) { @@ -814,12 +809,8 @@ namespace { else sf = 46; } - // Endings where weaker side can place his king in front of the enemy's - // pawns are drawish. - else if ( abs(eg) <= BishopValueEg - && pos.count(strongSide) <= 2 - && !pos.pawn_passed(~strongSide, pos.square(~strongSide))) - sf = 37 + 7 * pos.count(strongSide); + else + sf = std::min(40 + 7 * pos.count(strongSide), sf); } return ScaleFactor(sf);