diff --git a/src/endgame.cpp b/src/endgame.cpp index 835173c4..3e572205 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -286,6 +286,21 @@ Value Endgame::operator()(const Position& pos) const { } +/// KNN vs KP. Simply push the opposing king to the corner. +template<> +Value Endgame::operator()(const Position& pos) const { + + assert(verify_material(pos, strongSide, 2 * KnightValueMg, 0)); + assert(verify_material(pos, weakSide, VALUE_ZERO, 1)); + + Value result = 2 * KnightValueEg + - PawnValueEg + + PushToEdges[pos.square(weakSide)]; + + return strongSide == pos.side_to_move() ? result : -result; +} + + /// Some cases of trivial draws template<> Value Endgame::operator()(const Position&) const { return VALUE_DRAW; } diff --git a/src/endgame.h b/src/endgame.h index 941cb310..2a48488f 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -37,6 +37,7 @@ enum EndgameCode { EVALUATION_FUNCTIONS, KNNK, // KNN vs K + KNNKP, // KNN vs KP KXK, // Generic "mate lone king" eval KBNK, // KBN vs K KPK, // KP vs K @@ -125,6 +126,7 @@ public: add("KRKN"); add("KQKP"); add("KQKR"); + add("KNNKP"); add("KNPK"); add("KNPKB"); diff --git a/src/search.cpp b/src/search.cpp index 6bb1e1df..2e7dd698 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -830,7 +830,7 @@ namespace { int probCutCount = 0; while ( (move = mp.next_move()) != MOVE_NONE - && probCutCount < 2 + 2 * cutNode) + && probCutCount < 2 + 2 * cutNode) if (move != excludedMove && pos.legal(move)) { probCutCount++;