X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=c55013f3ac141f531c3bee0192a63ee4da85eb17;hp=f8f4c802d118441c09a5da4e405867605695a336;hb=48e39c5c8e671a37f09732d4a55d93d5e2d38550;hpb=13524bea9b7a64dd2881880b2272f3ccd494c262 diff --git a/src/endgame.cpp b/src/endgame.cpp index f8f4c802..c55013f3 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -101,57 +101,59 @@ namespace { /// Endgames member definitions -template<> const Endgames::EFMap& Endgames::get() const { return maps.first; } -template<> const Endgames::SFMap& Endgames::get() const { return maps.second; } +template<> const Endgames::EFMap& Endgames::map() const { return maps.first; } +template<> const Endgames::SFMap& Endgames::map() const { return maps.second; } Endgames::Endgames() { - add >("KNNK"); - add >("KPK"); - add >("KBNK"); - add >("KRKP"); - add >("KRKB"); - add >("KRKN"); - add >("KQKR"); - add >("KBBKN"); - - add >("KNPK"); - add >("KRPKR"); - add >("KBPKB"); - add >("KBPPKB"); - add >("KBPKN"); - add >("KRPPKRP"); + add("KPK"); + add("KNNK"); + add("KBNK"); + add("KRKP"); + add("KRKB"); + add("KRKN"); + add("KQKR"); + add("KBBKN"); + + add("KNPK"); + add("KRPKR"); + add("KBPKB"); + add("KBPKN"); + add("KBPPKB"); + add("KRPPKRP"); } Endgames::~Endgames() { - for (EFMap::const_iterator it = get().begin(); it != get().end(); ++it) + for (EFMap::const_iterator it = map().begin(); it != map().end(); ++it) delete it->second; - for (SFMap::const_iterator it = get().begin(); it != get().end(); ++it) + for (SFMap::const_iterator it = map().begin(); it != map().end(); ++it) delete it->second; } -template +template void Endgames::add(const string& keyCode) { - typedef typename T::Base F; - typedef std::map M; + typedef Endgame EG; + typedef typename EG::Base B; + typedef std::map M; - const_cast(get()).insert(std::pair(mat_key(keyCode), new T(WHITE))); - const_cast(get()).insert(std::pair(mat_key(swap_colors(keyCode)), new T(BLACK))); + const_cast(map()).insert(std::pair(mat_key(keyCode), new EG(WHITE))); + const_cast(map()).insert(std::pair(mat_key(swap_colors(keyCode)), new EG(BLACK))); } -template -T* Endgames::get(Key key) const { +template +EndgameBase* Endgames::get(Key key) const { - typename std::map::const_iterator it = get().find(key); - return it != get().end() ? it->second : NULL; + typedef EndgameBase E; + typename std::map::const_iterator it = map().find(key); + return it != map().end() ? it->second : NULL; } // Explicit template instantiations -template EF* Endgames::get(Key key) const; -template SF* Endgames::get(Key key) const; +template EF* Endgames::get(Key key) const; +template SF* Endgames::get(Key key) const; /// Mate with KX vs K. This function is used to evaluate positions with