X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=681b290c4711edd8d2d08fe92dd3afcc24b67fb0;hp=ee6705aaeaa0a157b70f94a06cfc87642d5b8b96;hb=3e4fed3a91752da394f7c912f4e5e29dc39391f6;hpb=e6310b3469b07b6bbecf8d8f75367a655090f22b diff --git a/src/endgame.cpp b/src/endgame.cpp index ee6705aa..681b290c 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -59,6 +59,9 @@ namespace { const int PushClose[8] = { 0, 0, 100, 80, 60, 40, 20, 10 }; const int PushAway [8] = { 0, 5, 20, 40, 60, 80, 90, 100 }; + // Pawn Rank based scaling factors used in KRPPKRP endgame + const int KRPPKRPScaleFactors[RANK_NB] = { 0, 9, 10, 14, 21, 44, 0, 0 }; + #ifndef NDEBUG bool verify_material(const Position& pos, Color c, Value npm, int pawnsCnt) { return pos.non_pawn_material(c) == npm && pos.count(c) == pawnsCnt; @@ -160,7 +163,7 @@ Value Endgame::operator()(const Position& pos) const { ||(pos.count(strongSide) && pos.count(strongSide)) ||(pos.count(strongSide) > 1 && opposite_colors(pos.squares(strongSide)[0], pos.squares(strongSide)[1]))) - result += VALUE_KNOWN_WIN; + result = std::min(result + VALUE_KNOWN_WIN, VALUE_MATE_IN_MAX_PLY - 1); return strongSide == pos.side_to_move() ? result : -result; } @@ -600,14 +603,8 @@ ScaleFactor Endgame::operator()(const Position& pos) const { && distance(bksq, wpsq2) <= 1 && relative_rank(strongSide, bksq) > r) { - switch (r) { - case RANK_2: return ScaleFactor(10); - case RANK_3: return ScaleFactor(10); - case RANK_4: return ScaleFactor(15); - case RANK_5: return ScaleFactor(20); - case RANK_6: return ScaleFactor(40); - default: assert(false); - } + assert(r > RANK_1 && r < RANK_7); + return ScaleFactor(KRPPKRPScaleFactors[r]); } return SCALE_FACTOR_NONE; }