X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=b63615a95ce439094835e8631128b699953e5188;hp=945fb4e44299dafab044810ac09ae72d4e6c0142;hb=ee5514b8fdc6583d134985edd2f875e197830030;hpb=e95e69515a8e30bcdcef84bd37656c3ea3099cd5 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 945fb4e4..b63615a9 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -372,7 +372,7 @@ Value do_evaluate(const Position& pos, Value& margin) { if (ei.mi->space_weight()) { int s = evaluate_space(pos, ei) - evaluate_space(pos, ei); - score += apply_weight(make_score(s * ei.mi->space_weight(), 0), Weights[Space]); + score += apply_weight(s * ei.mi->space_weight(), Weights[Space]); } // Scale winning side if position is more drawish that what it appears @@ -410,8 +410,8 @@ Value do_evaluate(const Position& pos, Value& margin) { Tracing::add(IMBALANCE, ei.mi->material_value()); Tracing::add(PAWN, ei.pi->pawns_value()); Tracing::add(UNSTOPPABLE, evaluate_unstoppable_pawns(pos, ei)); - Score w = make_score(ei.mi->space_weight() * evaluate_space(pos, ei), 0); - Score b = make_score(ei.mi->space_weight() * evaluate_space(pos, ei), 0); + Score w = ei.mi->space_weight() * evaluate_space(pos, ei); + Score b = ei.mi->space_weight() * evaluate_space(pos, ei); Tracing::add(SPACE, apply_weight(w, Weights[Space]), apply_weight(b, Weights[Space])); Tracing::add(TOTAL, score); Tracing::stream << "\nUncertainty margin: White: " << to_cp(margins[WHITE]) @@ -509,7 +509,9 @@ Value do_evaluate(const Position& pos, Value& margin) { ei.kingAdjacentZoneAttacksCount[Us] += popcount(bb); } - int mob = popcount(b & mobilityArea); + int mob = Piece != QUEEN ? popcount(b & mobilityArea) + : popcount(b & mobilityArea); + mobility += MobilityBonus[Piece][mob]; // Decrease score if we are attacked by an enemy pawn. Remaining part @@ -530,7 +532,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // Bishop and knight outposts squares if ( (Piece == BISHOP || Piece == KNIGHT) - && !(pos.pieces(Them, PAWN) & attack_span_mask(Us, s))) + && !(pos.pieces(Them, PAWN) & pawn_attack_span(Us, s))) score += evaluate_outposts(pos, ei, s); if ( (Piece == ROOK || Piece == QUEEN) @@ -554,7 +556,7 @@ Value do_evaluate(const Position& pos, Value& margin) { if (ei.pi->semiopen(Us, file_of(s))) score += ei.pi->semiopen(Them, file_of(s)) ? RookOpenFile : RookSemiopenFile; - if (mob > 6 || ei.pi->semiopen(Us, file_of(s))) + if (mob > 3 || ei.pi->semiopen(Us, file_of(s))) continue; Square ksq = pos.king_square(Us); @@ -765,7 +767,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // 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. score -= KingDanger[Us == Search::RootColor][attackUnits]; - margins[Us] += mg_value(KingDanger[Us == Search::RootColor][attackUnits]); + margins[Us] += mg_value(KingDanger[Us == Search::RootColor][attackUnits]) / 2; } if (Trace) @@ -821,7 +823,8 @@ Value do_evaluate(const Position& pos, Value& margin) { // If there is an enemy rook or queen attacking the pawn from behind, // add all X-ray attacks by the rook or queen. Otherwise consider only // the squares in the pawn's path attacked or occupied by the enemy. - if (forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN) & pos.attacks_from(s)) + if ( unlikely(forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN)) + && (forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN) & pos.attacks_from(s))) unsafeSquares = squaresToQueen; else unsafeSquares = squaresToQueen & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them)); @@ -989,7 +992,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // black pawns: a4, b4 white: b2 then pawn in b4 is giving support. if (!opposed) { - b2 = supporters & in_front_bb(winnerSide, blockSq + pawn_push(winnerSide)); + b2 = supporters & in_front_bb(winnerSide, rank_of(blockSq + pawn_push(winnerSide))); while (b2) // This while-loop could be replaced with LSB/MSB (depending on color) { @@ -999,7 +1002,7 @@ Value do_evaluate(const Position& pos, Value& margin) { } // Check pawns that can be sacrificed against the blocking pawn - b2 = attack_span_mask(winnerSide, blockSq) & candidates & ~(1ULL << s); + b2 = pawn_attack_span(winnerSide, blockSq) & candidates & ~(1ULL << s); while (b2) // This while-loop could be replaced with LSB/MSB (depending on color) { @@ -1141,7 +1144,7 @@ Value do_evaluate(const Position& pos, Value& margin) { stream.str(""); stream << std::showpoint << std::showpos << std::fixed << std::setprecision(2); - memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score)); + std::memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score)); Value margin; do_evaluate(pos, margin);