X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=da4860fe1ce25b26ae89d44fa97b6392a4ae23ba;hp=9c960409c5d514dd1512ff11c933da272b84457e;hb=c7a932bc744f899f53ce0013cbbbaa86915bb2e8;hpb=d73eea3f719aaa2867917155bd41b10a04958658 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 9c960409..da4860fe 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -23,7 +23,6 @@ //// #include -#include #include "bitcount.h" #include "evaluate.h" @@ -248,8 +247,6 @@ Value do_evaluate(const Position& pos, EvalInfo& ei) { assert(pos.thread() >= 0 && pos.thread() < MAX_THREADS); assert(!pos.is_check()); - memset(&ei, 0, sizeof(EvalInfo)); - // Initialize by reading the incrementally updated scores included in the // position object (material + piece square tables). ei.value = pos.value(); @@ -430,8 +427,8 @@ namespace { ei.kingZone[Us] = (b | (Us == WHITE ? b >> 8 : b << 8)); ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us); b &= ei.attackedBy[Us][PAWN]; - if (b) - ei.kingAttackersCount[Us] = count_1s_max_15(b) / 2; + ei.kingAttackersCount[Us] = b ? count_1s_max_15(b) / 2 : 0; + ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0; } @@ -475,6 +472,8 @@ namespace { const Color Them = (Us == WHITE ? BLACK : WHITE); const Square* ptr = pos.piece_list_begin(Us, Piece); + ei.attackedBy[Us][Piece] = 0; + while ((s = *ptr++) != SQ_NONE) { // Find attacked squares, including x-ray attacks for bishops and rooks @@ -710,13 +709,14 @@ namespace { attackUnits = Min(99, Max(0, attackUnits)); // Finally, extract the king danger score from the KingDangerTable[] - // array and subtract the score from evaluation. Set also ei.kingDanger[] + // array and subtract the score from evaluation. Set also ei.margin[] // value that will be used for pruning because this value can sometimes // be very big, and so capturing a single attacking piece can therefore // result in a score change far bigger than the value of the captured piece. ei.value -= Sign[Us] * KingDangerTable[Us][attackUnits]; - ei.kingDanger[Us] = mg_value(KingDangerTable[Us][attackUnits]); - } + ei.margin[Us] = mg_value(KingDangerTable[Us][attackUnits]); + } else + ei.margin[Us] = VALUE_ZERO; } @@ -727,11 +727,14 @@ namespace { const Color Them = (Us == WHITE ? BLACK : WHITE); + Score bonus = SCORE_ZERO; Bitboard squaresToQueen, defendedSquares, unsafeSquares, supportingPawns; Bitboard b = ei.pi->passed_pawns(Us); - while (b) - { + if (!b) + return; + + do { Square s = pop_1st_bit(&b); assert(pos.pawn_is_passed(Us, s)); @@ -806,11 +809,12 @@ namespace { else if (pos.pieces(ROOK, QUEEN, Them)) ebonus -= ebonus / 4; } + bonus += make_score(mbonus, ebonus); - // Add the scores for this pawn to the middle game and endgame eval - ei.value += Sign[Us] * apply_weight(make_score(mbonus, ebonus), Weights[PassedPawns]); + } while (b); - } // while + // Add the scores to the middle game and endgame eval + ei.value += Sign[Us] * apply_weight(bonus, Weights[PassedPawns]); }