X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=82bf7b06908a5db47820f0a52627991da6e2f5c2;hp=db08b1c49e22179fee74b556741104ec3c5d1567;hb=debc8153520f95c25c1045b723c70ddb4b0d7f80;hpb=dd8a07612843f32d4073135fc9e17b8814aa34a5 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index db08b1c4..82bf7b06 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -230,7 +230,7 @@ namespace { // Function prototypes template - Value do_evaluate(const Position& pos, Value margins[]); + Value do_evaluate(const Position& pos, Value& margin); template void init_eval_info(const Position& pos, EvalInfo& ei); @@ -239,7 +239,7 @@ namespace { Score evaluate_pieces_of_color(const Position& pos, EvalInfo& ei, Score& mobility); template - Score evaluate_king(const Position& pos, EvalInfo& ei, Value margins[]); + Score evaluate_king(const Position& pos, EvalInfo& ei, Value& margin); template Score evaluate_threats(const Position& pos, EvalInfo& ei); @@ -273,16 +273,16 @@ void prefetchPawn(Key key, int threadID) { /// evaluate() is the main evaluation function. It always computes two /// values, an endgame score and a middle game score, and interpolates /// between them based on the remaining material. -Value evaluate(const Position& pos, Value margins[]) { +Value evaluate(const Position& pos, Value& margin) { - return CpuHasPOPCNT ? do_evaluate(pos, margins) - : do_evaluate(pos, margins); + return CpuHasPOPCNT ? do_evaluate(pos, margin) + : do_evaluate(pos, margin); } namespace { template -Value do_evaluate(const Position& pos, Value margins[]) { +Value do_evaluate(const Position& pos, Value& margin) { EvalInfo ei; ScaleFactor factor[2]; @@ -296,9 +296,9 @@ Value do_evaluate(const Position& pos, Value margins[]) { // in the position object (material + piece square tables). Score bonus = pos.value(); - // margins[color] is the uncertainty estimation of position's evaluation + // margin is the uncertainty estimation of position's evaluation // and typically is used by the search for pruning decisions. - margins[WHITE] = margins[BLACK] = VALUE_ZERO; + margin = VALUE_ZERO; // Probe the material hash table MaterialInfo* mi = MaterialTable[pos.thread()]->get_material_info(pos); @@ -329,8 +329,8 @@ Value do_evaluate(const Position& pos, Value margins[]) { // Evaluate kings after all other pieces because we need complete attack // information when computing the king safety evaluation. - bonus += evaluate_king(pos, ei, margins) - - evaluate_king(pos, ei, margins); + bonus += evaluate_king(pos, ei, margin) + - evaluate_king(pos, ei, margin); // Evaluate tactical threats, we need full attack information including king bonus += evaluate_threats(pos, ei) @@ -663,7 +663,7 @@ namespace { // evaluate_king<>() assigns bonuses and penalties to a king of a given color template - Score evaluate_king(const Position& pos, EvalInfo& ei, Value margins[]) { + Score evaluate_king(const Position& pos, EvalInfo& ei, Value& margin) { const Color Them = (Us == WHITE ? BLACK : WHITE); @@ -764,7 +764,8 @@ namespace { // 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. bonus -= KingDangerTable[Us][attackUnits]; - margins[Us] += mg_value(KingDangerTable[Us][attackUnits]); + if (pos.side_to_move() == Us) + margin += mg_value(KingDangerTable[Us][attackUnits]); } return bonus; }