-}
-
-
-////
-//// Classes
-////
-
-/// EndgameFunctions class stores endgame evaluation and scaling functions
-/// in two std::map. Because STL library is not guaranteed to be thread
-/// safe even for read access, the maps, although with identical content,
-/// are replicated for each thread. This is faster then using locks.
-
-class EndgameFunctions {
-public:
- EndgameFunctions();
- ~EndgameFunctions();
- template<class T> T* get(Key key) const;
-
-private:
- template<class T> void add(const string& keyCode);
-
- static Key buildKey(const string& keyCode);
- static const string swapColors(const string& keyCode);
-
- // Here we store two maps, for evaluate and scaling functions...
- pair<EFMap, SFMap> maps;
-
- // ...and here is the accessing template function
- template<typename T> const map<Key, T*>& get() const;
-};
-
-// Explicit specializations of a member function shall be declared in
-// the namespace of which the class template is a member.
-template<> const EFMap& EndgameFunctions::get<EF>() const { return maps.first; }
-template<> const SFMap& EndgameFunctions::get<SF>() const { return maps.second; }
-
-
-////
-//// Functions
-////
-
-/// MaterialInfoTable c'tor and d'tor, called once by each thread
-
-MaterialInfoTable::MaterialInfoTable() {
-
- entries = new MaterialInfo[MaterialTableSize];
- funcs = new EndgameFunctions();
-
- if (!entries || !funcs)
- {
- cerr << "Failed to allocate " << MaterialTableSize * sizeof(MaterialInfo)
- << " bytes for material hash table." << endl;
- Application::exit_with_failure();
- }
-}
-
-MaterialInfoTable::~MaterialInfoTable() {
-
- delete funcs;
- delete [] entries;
-}
-
-
-/// MaterialInfoTable::game_phase() calculates the phase given the current
-/// position. Because the phase is strictly a function of the material, it
-/// is stored in MaterialInfo.