X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmaterial.cpp;h=cc90c2f9f620dbdc35d1571d1711e7f204cd42a5;hp=bd9d5e8a3e8d653b8d288ccc0f2dd2746e4cb41d;hb=d4b92ae9a094e1b388e3d70789a0db9a9c69cbdf;hpb=078354060ecb3f248cc1d719834073d46194d9d3 diff --git a/src/material.cpp b/src/material.cpp index bd9d5e8a..cc90c2f9 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -132,28 +132,8 @@ template<> const SFMap& EndgameFunctions::get() 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; - exit(EXIT_FAILURE); - } - memset(entries, 0, MaterialTableSize * sizeof(MaterialInfo)); -} - -MaterialInfoTable::~MaterialInfoTable() { - - delete funcs; - delete [] entries; -} - +MaterialInfoTable::MaterialInfoTable() { funcs = new EndgameFunctions(); } +MaterialInfoTable::~MaterialInfoTable() { delete funcs; } /// MaterialInfoTable::game_phase() calculates the phase given the current /// position. Because the phase is strictly a function of the material, it @@ -181,8 +161,7 @@ Phase MaterialInfoTable::game_phase(const Position& pos) { MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) { Key key = pos.get_material_key(); - unsigned index = unsigned(key & (MaterialTableSize - 1)); - MaterialInfo* mi = entries + index; + MaterialInfo* mi = find(key); // If mi->key matches the position's material hash key, it means that we // have analysed this material configuration before, and we can simply @@ -407,7 +386,7 @@ Key EndgameFunctions::buildKey(const string& keyCode) { } fen += char(8 - keyCode.length() + '0'); fen += "/8/8/8/8/8/8/8 w - -"; - return Position(fen, 0).get_material_key(); + return Position(fen, false, 0).get_material_key(); } const string EndgameFunctions::swapColors(const string& keyCode) {