X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.h;h=70f795cd19782c7a4aec23dd3c0217db51b4efd9;hp=e350022cce7351178333bf9ee11dc2b0ee175a2a;hb=b1cf1acb93532248fb10c2ca983d80389d5aeb84;hpb=4a8c1b24702ddf577853d72962cee6735a0235da diff --git a/src/endgame.h b/src/endgame.h index e350022c..70f795cd 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-2010 Marco Costalba, Joona Kiiski, Tord Romstad + Copyright (C) 2008-2012 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 @@ -20,8 +20,8 @@ #if !defined(ENDGAME_H_INCLUDED) #define ENDGAME_H_INCLUDED -#include #include +#include #include "position.h" #include "types.h" @@ -82,7 +82,7 @@ struct EndgameBase { template::type> struct Endgame : public EndgameBase { - explicit Endgame(Color c) : strongerSide(c), weakerSide(flip(c)) {} + explicit Endgame(Color c) : strongerSide(c), weakerSide(~c) {} Color color() const { return strongerSide; } T operator()(const Position&) const; @@ -97,30 +97,24 @@ private: class Endgames { - template - struct Map { typedef std::map*> type; }; + typedef std::map*> M1; + typedef std::map*> M2; + + M1 m1; + M2 m2; + + M1& map(Value*) { return m1; } + M2& map(ScaleFactor*) { return m2; } - typedef Map::type M1; - typedef Map::type M2; + template void add(const std::string& code); public: Endgames(); ~Endgames(); - template - EndgameBase* get(Key key) const { - - typedef typename Map::type M; - typename M::const_iterator it = map().find(key); - return it != map().end() ? it->second : NULL; + template EndgameBase* get(Key key) { + return map((T*)0).count(key) ? map((T*)0)[key] : NULL; } - -private: - template void add(const std::string& keyCode); - template const M& map() const; - - M1 m1; - M2 m2; }; #endif // !defined(ENDGAME_H_INCLUDED)