X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=d225de26fff69994013aabd9762dc373abe730f6;hp=1e8dae9585026ab8cda57e5f6e7834af57b965d4;hb=35ada63174bbec6289d6dea6d3cfc5b5f14d1d27;hpb=71e852ea815be8dd718685cb9e15ccdb8b756211 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 1e8dae95..d225de26 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -64,8 +64,7 @@ namespace { const Score WeightKingOppSafetyInternal = make_score(259, 0); // Mobility and outposts bonus modified by Joona Kiiski - // - // Visually better to define tables constants + typedef Value V; #define S(mg, eg) make_score(mg, eg) @@ -111,7 +110,7 @@ namespace { // Pointers table to access mobility tables through piece type const Score* MobilityBonus[8] = { 0, 0, KnightMobilityBonus, BishopMobilityBonus, - RookMobilityBonus, QueenMobilityBonus, 0, 0 }; + RookMobilityBonus, QueenMobilityBonus, 0, 0 }; // Outpost bonuses for knights and bishops, indexed by square (from white's // point of view). @@ -141,7 +140,7 @@ namespace { // ThreatBonus[][] contains bonus according to which piece type // attacks which one. - #define Z make_score(0, 0) + #define Z S(0, 0) const Score ThreatBonus[8][8] = { { Z, Z, Z, Z, Z, Z, Z, Z }, // not used @@ -252,9 +251,10 @@ namespace { // in init_safety(). Value SafetyTable[100]; - // Pawn and material hash tables, indexed by the current thread id - PawnInfoTable* PawnTable[8] = {0, 0, 0, 0, 0, 0, 0, 0}; - MaterialInfoTable* MaterialTable[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + // Pawn and material hash tables, indexed by the current thread id. + // Note that they will be initialized at 0 being global variables. + MaterialInfoTable* MaterialTable[THREAD_MAX]; + PawnInfoTable* PawnTable[THREAD_MAX]; // Sizes of pawn and material hash tables const int PawnTableSize = 16384; @@ -330,7 +330,7 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) { // Probe the pawn hash table ei.pi = PawnTable[threadID]->get_pawn_info(pos); - ei.value += apply_weight(ei.pi->value(), WeightPawnStructure); + ei.value += apply_weight(ei.pi->pawns_value(), WeightPawnStructure); // Initialize king attack bitboards and king attack zones for both sides ei.attackedBy[WHITE][KING] = pos.attacks_from(pos.king_square(WHITE)); @@ -436,21 +436,6 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) { } // namespace -/// quick_evaluate() does a very approximate evaluation of the current position. -/// It currently considers only material and piece square table scores. Perhaps -/// we should add scores from the pawn and material hash tables? - -Value quick_evaluate(const Position &pos) { - - assert(pos.is_ok()); - - static const ScaleFactor sf[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL}; - - Value v = scale_by_game_phase(pos.value(), MaterialInfoTable::game_phase(pos), sf); - return (pos.side_to_move() == WHITE ? v : -v); -} - - /// init_eval() initializes various tables used by the evaluation function void init_eval(int threads) { @@ -875,11 +860,8 @@ namespace { // capturing a single attacking piece can therefore result in a score // change far bigger than the value of the captured piece. Score v = apply_weight(make_score(SafetyTable[attackUnits], 0), WeightKingSafety[Us]); - ei.value -= Sign[Us] * v; - - if (Us == pos.side_to_move()) - ei.futilityMargin += mg_value(v); + ei.futilityMargin[Us] += mg_value(v); } }