X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.h;h=5ea40bbf91b995070a7bf804b52ecc8c0fec548e;hp=424a3591cb80e6a67b22c784f524621186d28a98;hb=45b0aea875860e9f0fe2d0435ee6163906639194;hpb=dda0fa1a43e1096415ff8f83dd14e6322f1a8e68 diff --git a/src/endgame.h b/src/endgame.h index 424a3591..5ea40bbf 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -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 . */ -#if !defined(ENDGAME_H_INCLUDED) +#ifndef ENDGAME_H_INCLUDED #define ENDGAME_H_INCLUDED #include @@ -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 void add(const std::string& code); public: Endgames(); - ~Endgames(); + ~Endgames(); - template EndgameBase* probe(Key key) { - return map((EndgameBase*)0).count(key) ? map((EndgameBase*)0)[key] : NULL; - } + template 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