X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmaterial.cpp;h=eb271e8c94b6701c7eab1a308a451454f242cd76;hp=8380ab8f6219c48a9b53e78d91e20d7b47a99fb5;hb=152f3b13b78d014dbc85204d6757e2cdf65e5ecf;hpb=044ad593b3c9fa8ab70f9b2ebfc2c36ce398eb5f diff --git a/src/material.cpp b/src/material.cpp index 8380ab8f..eb271e8c 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -28,7 +28,7 @@ #include "material.h" -using std::string; +using namespace std; //// //// Local definitions @@ -41,17 +41,17 @@ namespace { const Value BishopPairEndgameBonus = Value(97); // Polynomial material balance parameters - const Value RedundantQueenPenalty = Value(320); - const Value RedundantRookPenalty = Value(554); - const int LinearCoefficients[6] = { 1709, -137, -1185, -166, 141, 59 }; + const Value RedundantQueenPenalty = Value(358); + const Value RedundantRookPenalty = Value(536); + const int LinearCoefficients[6] = { 1740, -146, -1246, -197, 206, -7 }; const int QuadraticCoefficientsSameColor[][6] = { - { 0, 0, 0, 0, 0, 0 }, { 33, -6, 0, 0, 0, 0 }, { 29, 269, -12, 0, 0, 0 }, - { 0, 19, -4, 0, 0, 0 }, { -35, -10, 40, 95, 50, 0 }, { 52, 23, 78, 144, -11, -33 } }; + { 0, 0, 0, 0, 0, 0 }, { 31, -4, 0, 0, 0, 0 }, { 14, 267, -21, 0, 0, 0 }, + { 0, 7, -26, 0, 0, 0 }, { -3, -1, 69, 162, 80, 0 }, { 40, 27, 119, 174, -64, -49 } }; const int QuadraticCoefficientsOppositeColor[][6] = { - { 0, 0, 0, 0, 0, 0 }, { -5, 0, 0, 0, 0, 0 }, { -33, 23, 0, 0, 0, 0 }, - { 17, 25, -3, 0, 0, 0 }, { 10, -2, -19, -67, 0, 0 }, { 69, 64, -41, 116, 137, 0 } }; + { 0, 0, 0, 0, 0, 0 }, { -9, 0, 0, 0, 0, 0 }, { 49, 32, 0, 0, 0, 0 }, + { -25, 19, -5, 0, 0, 0 }, { 97, -6, 39, -88, 0, 0 }, { 77, 69, -42, 104, 116, 0 } }; // Unmapped endgame evaluation and scaling functions, these // are accessed direcly and not through the function maps. @@ -88,21 +88,21 @@ private: static Key buildKey(const string& keyCode); static const string swapColors(const string& keyCode); - std::map EEFmap; - std::map ESFmap; + // Here we store two maps, one for evaluate and one for scaling + pair, map > maps; // Maps accessing functions for const and non-const references - template const std::map& map() const { return EEFmap; } - template std::map& map() { return EEFmap; } + template const map& get() const { return maps.first; } + template map& get() { return maps.first; } }; // Explicit specializations of a member function shall be declared in // the namespace of which the class template is a member. -template<> const std::map& -EndgameFunctions::map() const { return ESFmap; } +template<> const map& +EndgameFunctions::get() const { return maps.second; } -template<> std::map& -EndgameFunctions::map() { return ESFmap; } +template<> map& +EndgameFunctions::get() { return maps.second; } //// @@ -119,8 +119,8 @@ MaterialInfoTable::MaterialInfoTable(unsigned int numOfEntries) { funcs = new EndgameFunctions(); if (!entries || !funcs) { - std::cerr << "Failed to allocate " << (numOfEntries * sizeof(MaterialInfo)) - << " bytes for material hash table." << std::endl; + cerr << "Failed to allocate " << (numOfEntries * sizeof(MaterialInfo)) + << " bytes for material hash table." << endl; Application::exit_with_failure(); } } @@ -370,10 +370,10 @@ EndgameFunctions::EndgameFunctions() { EndgameFunctions::~EndgameFunctions() { - for (std::map::iterator it = EEFmap.begin(); it != EEFmap.end(); ++it) + for (map::iterator it = maps.first.begin(); it != maps.first.end(); ++it) delete (*it).second; - for (std::map::iterator it = ESFmap.begin(); it != ESFmap.end(); ++it) + for (map::iterator it = maps.second.begin(); it != maps.second.end(); ++it) delete (*it).second; } @@ -382,7 +382,7 @@ Key EndgameFunctions::buildKey(const string& keyCode) { assert(keyCode.length() > 0 && keyCode[0] == 'K'); assert(keyCode.length() < 8); - std::stringstream s; + stringstream s; bool upcase = false; // Build up a fen substring with the given pieces, note @@ -410,13 +410,13 @@ void EndgameFunctions::add(const string& keyCode) { typedef typename T::Base F; - map().insert(std::pair(buildKey(keyCode), new T(WHITE))); - map().insert(std::pair(buildKey(swapColors(keyCode)), new T(BLACK))); + get().insert(pair(buildKey(keyCode), new T(WHITE))); + get().insert(pair(buildKey(swapColors(keyCode)), new T(BLACK))); } template T* EndgameFunctions::get(Key key) const { - typename std::map::const_iterator it(map().find(key)); - return (it != map().end() ? it->second : NULL); + typename map::const_iterator it(get().find(key)); + return (it != get().end() ? it->second : NULL); }