]> git.sesse.net Git - stockfish/blobdiff - src/endgame.cpp
There is no need to special case KNNK ending
[stockfish] / src / endgame.cpp
index 90898e8341a58987b46cb0433018cb4d587484e8..abbb0876c64bd35b77be6f919ca66b793d02c4cb 100644 (file)
 #include "endgame.h"
 
 
-////
-//// Constants and variables
-////
-
-/// Evaluation functions
-
-// Generic "mate lone king" eval
-EvaluationFunction<KXK> EvaluateKXK(WHITE), EvaluateKKX(BLACK);
-
-// K and two minors vs K and one or two minors
-EvaluationFunction<KmmKm> EvaluateKmmKm(WHITE);
-
-EvaluationFunction<KBNK> EvaluateKBNK(WHITE), EvaluateKKBN(BLACK); // KBN vs K
-EvaluationFunction<KPK> EvaluateKPK(WHITE), EvaluateKKP(BLACK);    // KP vs K
-EvaluationFunction<KRKP> EvaluateKRKP(WHITE), EvaluateKPKR(BLACK); // KR vs KP
-EvaluationFunction<KRKB> EvaluateKRKB(WHITE), EvaluateKBKR(BLACK); // KR vs KB
-EvaluationFunction<KRKN> EvaluateKRKN(WHITE), EvaluateKNKR(BLACK); // KR vs KN
-EvaluationFunction<KQKR> EvaluateKQKR(WHITE), EvaluateKRKQ(BLACK); // KQ vs KR
-EvaluationFunction<KBBKN> EvaluateKBBKN(WHITE), EvaluateKNKBB(BLACK); // KBB vs KN
-
-
-/// Scaling functions
-
-ScalingFunction<KBPK> ScaleKBPK(WHITE), ScaleKKBP(BLACK);    // KBP vs K
-ScalingFunction<KQKRP> ScaleKQKRP(WHITE), ScaleKRPKQ(BLACK); // KQ vs KRP
-ScalingFunction<KRPKR> ScaleKRPKR(WHITE), ScaleKRKRP(BLACK); // KRP vs KR
-ScalingFunction<KRPPKRP> ScaleKRPPKRP(WHITE), ScaleKRPKRPP(BLACK); // KRPP vs KRP
-ScalingFunction<KPsK> ScaleKPsK(WHITE), ScaleKKPs(BLACK);    // King and pawns vs king
-ScalingFunction<KBPKB> ScaleKBPKB(WHITE), ScaleKBKBP(BLACK); // KBP vs KB
-ScalingFunction<KBPPKB> ScaleKBPPKB(WHITE), ScaleKBKBPP(BLACK); // KBPP vs KB
-ScalingFunction<KBPKN> ScaleKBPKN(WHITE), ScaleKNKBP(BLACK); // KBP vs KN
-ScalingFunction<KNPK> ScaleKNPK(WHITE), ScaleKKNP(BLACK);    // KNP vs K
-ScalingFunction<KPKP> ScaleKPKPw(WHITE), ScaleKPKPb(BLACK);  // KPKP
-
-
 ////
 //// Local definitions
 ////
@@ -378,16 +343,23 @@ Value EvaluationFunction<KBBKN>::apply(const Position& pos) {
   result += Value(square_distance(bksq, nsq) * 32);
 
   // Bonus for restricting the knight's mobility
-  result += Value((8 - count_1s_max_15<false>(pos.piece_attacks<KNIGHT>(nsq))) * 8);
+  result += Value((8 - count_1s_max_15(pos.piece_attacks<KNIGHT>(nsq))) * 8);
 
   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<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