]> git.sesse.net Git - stockfish/blobdiff - src/endgame.h
Revert "Fix random moves when time < 10ms"
[stockfish] / src / endgame.h
index 424a3591cb80e6a67b22c784f524621186d28a98..5ea40bbf91b995070a7bf804b52ecc8c0fec548e 100644 (file)
@@ -1,7 +1,7 @@
 /*
   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
   Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-  Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad
+  Copyright (C) 2008-2013 Marco Costalba, Joona Kiiski, Tord Romstad
 
   Stockfish is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#if !defined(ENDGAME_H_INCLUDED)
+#ifndef ENDGAME_H_INCLUDED
 #define ENDGAME_H_INCLUDED
 
 #include <map>
@@ -33,16 +33,17 @@ enum EndgameType {
 
   // Evaluation functions
 
+  KNNK,  // KNN vs K
   KXK,   // Generic "mate lone king" eval
   KBNK,  // KBN vs K
   KPK,   // KP vs K
   KRKP,  // KR vs KP
   KRKB,  // KR vs KB
   KRKN,  // KR vs KN
+  KQKP,  // KQ vs KP
   KQKR,  // KQ vs KR
   KBBKN, // KBB vs KN
-  KNNK,  // KNN vs K
-  KmmKm, // K and two minors vs K and one or two minors
+  KmmKm, // K and one or two minors vs K and zero or one minor
 
 
   // Scaling functions
@@ -57,6 +58,7 @@ enum EndgameType {
   KBPPKB,  // KBPP vs KB
   KBPKN,   // KBP vs KN
   KNPK,    // KNP vs K
+  KNPKB,   // KNP vs KB
   KPKP     // KP vs KP
 };
 
@@ -94,7 +96,7 @@ private:
 
 /// Endgames class stores in two std::map the pointers to endgame evaluation
 /// and scaling base objects. Then we use polymorphism to invoke the actual
-/// endgame function calling its operator() method that is virtual.
+/// endgame function calling its operator() that is virtual.
 
 class Endgames {
 
@@ -104,18 +106,17 @@ class Endgames {
   M1 m1;
   M2 m2;
 
-  M1& map(M1::value_type::second_type) { return m1; }
-  M2& map(M2::value_type::second_type) { return m2; }
+  M1& map(M1::mapped_type) { return m1; }
+  M2& map(M2::mapped_type) { return m2; }
 
   template<EndgameType E> void add(const std::string& code);
 
 public:
   Endgames();
 ~Endgames();
+ ~Endgames();
 
-  template<typename T> EndgameBase<T>* probe(Key key) {
-    return map((EndgameBase<T>*)0).count(key) ? map((EndgameBase<T>*)0)[key] : NULL;
-  }
+  template<typename T> T probe(Key key, T& eg)
+  { return eg = map(eg).count(key) ? map(eg)[key] : NULL; }
 };
 
-#endif // !defined(ENDGAME_H_INCLUDED)
+#endif // #ifndef ENDGAME_H_INCLUDED