]> git.sesse.net Git - stockfish/commitdiff
There is no need to special case KNNK ending
authorMarco Costalba <mcostalba@gmail.com>
Sat, 8 Aug 2009 11:28:03 +0000 (12:28 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 8 Aug 2009 12:10:10 +0000 (13:10 +0100)
It is always draw, so use the corresponding proper
evaluation function.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/endgame.cpp
src/endgame.h
src/material.cpp

index a8c1e1d01ffb4d4803fbc1a957bd25366a2b85a7..abbb0876c64bd35b77be6f919ca66b793d02c4cb 100644 (file)
@@ -348,11 +348,18 @@ Value EvaluationFunction<KBBKN>::apply(const Position& pos) {
   return (strongerSide == pos.side_to_move() ? result : -result);
 }
 
   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<KmmKm>::apply(const Position&) {
   return Value(0);
 }
 
 template<>
 Value EvaluationFunction<KmmKm>::apply(const Position&) {
   return Value(0);
 }
 
+template<>
+Value EvaluationFunction<KNNK>::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
 
 /// KBPKScalingFunction scales endgames where the stronger side has king,
 /// bishop and one or more pawns. It checks for draws with rook pawns and a
index 4426ef186c5bacd4347bf94f712cbe08fef7a88a..43a685572aa710f15c5a9da2b037ddb23309d175 100644 (file)
@@ -45,6 +45,7 @@ enum EndgameType {
     KRKN,  // KR vs KN
     KQKR,  // KQ vs KR
     KBBKN, // KBB vs KN
     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
     KmmKm, // K and two minors vs K and one or two minors
 
     // Scaling functions
index 885140c06ceda9266184f88521dcc96945f60aae..a8ecb51a5a3377a6a7153951e4e13c53e89c528a 100644 (file)
@@ -61,8 +61,6 @@ namespace {
   ScalingFunction<KQKRP>    ScaleKQKRP(WHITE),  ScaleKRPKQ(BLACK);
   ScalingFunction<KPsK>     ScaleKPsK(WHITE),   ScaleKKPs(BLACK);
   ScalingFunction<KPKP>     ScaleKPKPw(WHITE),  ScaleKPKPb(BLACK);
   ScalingFunction<KQKRP>    ScaleKQKRP(WHITE),  ScaleKRPKQ(BLACK);
   ScalingFunction<KPsK>     ScaleKPsK(WHITE),   ScaleKKPs(BLACK);
   ScalingFunction<KPKP>     ScaleKPKPw(WHITE),  ScaleKPKPb(BLACK);
-
-  Key KNNKMaterialKey, KKNNMaterialKey;
 }
 
 
 }
 
 
@@ -157,14 +155,6 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
   mi->clear();
   mi->key = key;
 
   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.
   // 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() {
 
 
 EndgameFunctions::EndgameFunctions() {
 
-  KNNKMaterialKey = buildKey("KNNK");
-  KKNNMaterialKey = buildKey("KKNN");
-
+  add<EvaluationFunction<KNNK>  >("KNNK");
   add<EvaluationFunction<KPK>   >("KPK");
   add<EvaluationFunction<KBNK>  >("KBNK");
   add<EvaluationFunction<KRKP>  >("KRKP");
   add<EvaluationFunction<KPK>   >("KPK");
   add<EvaluationFunction<KBNK>  >("KBNK");
   add<EvaluationFunction<KRKP>  >("KRKP");