From: Stefano80 Date: Sat, 24 Oct 2015 22:12:59 +0000 (+0100) Subject: KRPPKRP endgame: Simplify ugly switch statement X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=3428a2875197c805c25fdd954ba3a24d00845a2a KRPPKRP endgame: Simplify ugly switch statement No functional change Resolves #470 --- diff --git a/src/endgame.cpp b/src/endgame.cpp index 97e7e12f..ed6d48db 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; @@ -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(9); - case RANK_3: return ScaleFactor(10); - case RANK_4: return ScaleFactor(14); - case RANK_5: return ScaleFactor(21); - case RANK_6: return ScaleFactor(44); - default: assert(false); - } + assert(r > RANK_1 && r < RANK_7); + return ScaleFactor(KRPPKRPScaleFactors[r]); } return SCALE_FACTOR_NONE; }