X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=03d537d52bc42bdfb7678167fae89969b7b2a434;hp=897fc778a467ded318fbbba61f0dc047af32845a;hb=307a5a4f63169fd215860dc478dcf2a9db2c46e8;hpb=55758344d3ccf49353bcd8f3a06a4553ff1b753a diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 897fc778..03d537d5 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -171,8 +171,8 @@ namespace { // PassedFile[File] contains a bonus according to the file of a passed pawn. const Score PassedFile[] = { - S( 12, 10), S( 3, 10), S( 1, -8), S(-27, -12), - S(-27, -12), S( 1, -8), S( 3, 10), S( 12, 10) + S( 12, 10), S( 3, 10), S( 1, -8), S(-27, -12), + S(-27, -12), S( 1, -8), S( 3, 10), S( 12, 10) }; const Score ThreatenedByHangingPawn = S(40, 60); @@ -677,20 +677,18 @@ namespace { // evaluate_initiative() computes the initiative correction value for the // position, i.e. second order bonus/malus based on the known attacking/defending // status of the players. - Score evaluate_initiative(const Position& pos, const EvalInfo& ei, const Score positional_score) { + Score evaluate_initiative(const Position& pos, int asymmetry, Value eg) { - int king_separation = distance(pos.square(WHITE), pos.square(BLACK)); - int pawns = pos.count(WHITE) + pos.count(BLACK); - int asymmetry = ei.pi->pawn_asymmetry(); + int kingDistance = distance(pos.square(WHITE), pos.square(BLACK)); + int pawns = pos.count(WHITE) + pos.count(BLACK); // Compute the initiative bonus for the attacking side - int attacker_bonus = 8 * (pawns + asymmetry + king_separation) - 120; + int initiative = 8 * (pawns + asymmetry + kingDistance - 15); - // Now apply the bonus: note that we find the attacking side by extracting the sign - // of the endgame value of "positional_score", and that we carefully cap the bonus so - // that the endgame score with the correction will never be divided by more than two. - int eg = eg_value(positional_score); - int value = ((eg > 0) - (eg < 0)) * std::max(attacker_bonus, -abs(eg / 2)); + // Now apply the bonus: note that we find the attacking side by extracting + // the sign of the endgame value, and that we carefully cap the bonus so + // that the endgame score will never be divided by more than two. + int value = ((eg > 0) - (eg < 0)) * std::max(initiative, -abs(eg / 2)); return make_score(0, value); } @@ -777,8 +775,8 @@ Value Eval::evaluate(const Position& pos) { if (pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) >= 12222) score += (evaluate_space(pos, ei) - evaluate_space(pos, ei)) * Weights[Space]; - // Evaluate initiative - score += evaluate_initiative(pos, ei, score); + // Evaluate position potential for the winning side + score += evaluate_initiative(pos, ei.pi->pawn_asymmetry(), eg_value(score)); // Scale winning side if position is more drawish than it appears Color strongSide = eg_value(score) > VALUE_DRAW ? WHITE : BLACK;