From: Marco Costalba Date: Sat, 8 Aug 2009 11:28:03 +0000 (+0100) Subject: There is no need to special case KNNK ending X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=aa925a0e2905042a978860a75798398cb79b2600;hp=23ceb6695073cef741253ab175fabfde48415463;p=stockfish There is no need to special case KNNK ending It is always draw, so use the corresponding proper evaluation function. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/endgame.cpp b/src/endgame.cpp index a8c1e1d0..abbb0876 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -348,11 +348,18 @@ Value EvaluationFunction::apply(const Position& pos) { return (strongerSide == pos.side_to_move() ? result : -result); } + +/// K and two minors vs K and one or two minors or K and two knights against +/// king alone are always draw. template<> Value EvaluationFunction::apply(const Position&) { return Value(0); } +template<> +Value EvaluationFunction::apply(const Position&) { + return Value(0); +} /// KBPKScalingFunction scales endgames where the stronger side has king, /// bishop and one or more pawns. It checks for draws with rook pawns and a diff --git a/src/endgame.h b/src/endgame.h index 4426ef18..43a68557 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -45,6 +45,7 @@ enum EndgameType { KRKN, // KR vs KN KQKR, // KQ vs KR KBBKN, // KBB vs KN + KNNK, // KNN vs K KmmKm, // K and two minors vs K and one or two minors // Scaling functions diff --git a/src/material.cpp b/src/material.cpp index 885140c0..a8ecb51a 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -61,8 +61,6 @@ namespace { ScalingFunction ScaleKQKRP(WHITE), ScaleKRPKQ(BLACK); ScalingFunction ScaleKPsK(WHITE), ScaleKKPs(BLACK); ScalingFunction ScaleKPKPw(WHITE), ScaleKPKPb(BLACK); - - Key KNNKMaterialKey, KKNNMaterialKey; } @@ -157,14 +155,6 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) { mi->clear(); mi->key = key; - // A special case before looking for a specialized evaluation function - // KNN vs K is a draw. - if (key == KNNKMaterialKey || key == KKNNMaterialKey) - { - mi->factor[WHITE] = mi->factor[BLACK] = 0; - return mi; - } - // Let's look if we have a specialized evaluation function for this // particular material configuration. First we look for a fixed // configuration one, then a generic one if previous search failed. @@ -348,9 +338,7 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) { EndgameFunctions::EndgameFunctions() { - KNNKMaterialKey = buildKey("KNNK"); - KKNNMaterialKey = buildKey("KKNN"); - + add >("KNNK"); add >("KPK"); add >("KBNK"); add >("KRKP");