X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.h;fp=src%2Fendgame.h;h=81afb2e55478ccbd62764c009d43f3cbf7cdc22f;hp=2a48488fcd8ce2636849cb01b078cfc984e7cb9e;hb=4a7b8180ecaef7d164fa53a1d545372df1173596;hpb=44c320a572188b5875291103edb344c584b91d19 diff --git a/src/endgame.h b/src/endgame.h index 2a48488f..81afb2e5 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -95,10 +95,12 @@ struct Endgame : public EndgameBase { /// base objects in two std::map. We use polymorphism to invoke the actual /// endgame function by calling its virtual operator(). -class Endgames { +namespace Endgames { template using Ptr = std::unique_ptr>; template using Map = std::map>; + + extern std::pair, Map> maps; template Map& map() { @@ -113,35 +115,12 @@ class Endgames { map()[Position().set(code, BLACK, &st).material_key()] = Ptr(new Endgame(BLACK)); } - std::pair, Map> maps; - -public: - Endgames() { - - add("KPK"); - add("KNNK"); - add("KBNK"); - add("KRKP"); - add("KRKB"); - add("KRKN"); - add("KQKP"); - add("KQKR"); - add("KNNKP"); - - add("KNPK"); - add("KNPKB"); - add("KRPKR"); - add("KRPKB"); - add("KBPKB"); - add("KBPKN"); - add("KBPPKB"); - add("KRPPKRP"); - } - template const EndgameBase* probe(Key key) { return map().count(key) ? map()[key].get() : nullptr; } -}; + + void init(); +} #endif // #ifndef ENDGAME_H_INCLUDED