X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmaterial.cpp;h=71e057a7116d10d7bdb36602eb4f507de0dcd13a;hb=812e843939a9577e5a546696259af4aa62e6758f;hp=ffc549ca6962bb637e9d23059bb991a76f792563;hpb=94b9c65e09b5d396bebb29b62d9979139b5fbdfa;p=stockfish diff --git a/src/material.cpp b/src/material.cpp index ffc549ca..71e057a7 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -23,6 +23,7 @@ //// #include +#include #include #include @@ -134,15 +135,14 @@ template<> const SFMap& EndgameFunctions::get() const { return maps.second; /// MaterialInfoTable c'tor and d'tor, called once by each thread -MaterialInfoTable::MaterialInfoTable(unsigned int numOfEntries) { +MaterialInfoTable::MaterialInfoTable() { - size = numOfEntries; - entries = new MaterialInfo[size]; + entries = new MaterialInfo[MaterialTableSize]; funcs = new EndgameFunctions(); if (!entries || !funcs) { - cerr << "Failed to allocate " << numOfEntries * sizeof(MaterialInfo) + cerr << "Failed to allocate " << MaterialTableSize * sizeof(MaterialInfo) << " bytes for material hash table." << endl; Application::exit_with_failure(); } @@ -181,7 +181,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 & (size - 1)); + unsigned index = unsigned(key & (MaterialTableSize - 1)); MaterialInfo* mi = entries + index; // If mi->key matches the position's material hash key, it means that we @@ -191,7 +191,8 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) { return mi; // Clear the MaterialInfo object, and set its key - mi->clear(); + memset(mi, 0, sizeof(MaterialInfo)); + mi->factor[WHITE] = mi->factor[BLACK] = uint8_t(SCALE_FACTOR_NORMAL); mi->key = key; // Store game phase @@ -332,7 +333,7 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) { // Second-degree polynomial material imbalance by Tord Romstad // - // We use NO_PIECE_TYPE as a place holder for the bishop pair "extended piece", + // We use PIECE_TYPE_NONE as a place holder for the bishop pair "extended piece", // this allow us to be more flexible in defining bishop pair bonuses. for (pt1 = PIECE_TYPE_NONE; pt1 <= QUEEN; pt1++) {