X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=340a342fc62f0148bdcd2b108d309ba8545bbb9c;hp=12634ddd56b0a41ec937d88e3073dd9e623c378d;hb=0515ad0fb0f2d46ee60288b0541cea495e6c90ef;hpb=27e9fc10671dffab5c278afac385771946cfab8c diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 12634ddd..340a342f 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -114,16 +114,15 @@ namespace { S( 37, 28), S( 42, 31), S(44, 33) }, { S(-22,-27), S( -8,-13), S( 6, 1), S(20, 15), S(34, 29), S(48, 43), // Bishops S( 60, 55), S( 68, 63), S(74, 68), S(77, 72), S(80, 75), S(82, 77), - S( 84, 79), S( 86, 81), S(87, 82), S(87, 82) }, + S( 84, 79), S( 86, 81) }, { S(-17,-33), S(-11,-16), S(-5, 0), S( 1, 16), S( 7, 32), S(13, 48), // Rooks S( 18, 64), S( 22, 80), S(26, 96), S(29,109), S(31,115), S(33,119), - S( 35,122), S( 36,123), S(37,124), S(38,124) }, + S( 35,122), S( 36,123), S(37,124) }, { S(-12,-20), S( -8,-13), S(-5, -7), S(-2, -1), S( 1, 5), S( 4, 11), // Queens S( 7, 17), S( 10, 23), S(13, 29), S(16, 34), S(18, 38), S(20, 40), S( 22, 41), S( 23, 41), S(24, 41), S(25, 41), S(25, 41), S(25, 41), S( 25, 41), S( 25, 41), S(25, 41), S(25, 41), S(25, 41), S(25, 41), - S( 25, 41), S( 25, 41), S(25, 41), S(25, 41), S(25, 41), S(25, 41), - S( 25, 41), S( 25, 41) } + S( 25, 41), S( 25, 41), S(25, 41), S(25, 41) } }; // Outpost[PieceType][Square] contains bonuses of knights and bishops, indexed @@ -826,7 +825,6 @@ Value do_evaluate(const Position& pos, Value& margin) { if (pos.is_empty(blockSq)) { squaresToQueen = forward_bb(Us, s); - defendedSquares = squaresToQueen & ei.attackedBy[Us][ALL_PIECES]; // 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 @@ -837,6 +835,12 @@ Value do_evaluate(const Position& pos, Value& margin) { else unsafeSquares = squaresToQueen & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them)); + if ( unlikely(forward_bb(Them, s) & pos.pieces(Us, ROOK, QUEEN)) + && (forward_bb(Them, s) & pos.pieces(Us, ROOK, QUEEN) & pos.attacks_from(s))) + defendedSquares = squaresToQueen; + else + defendedSquares = squaresToQueen & ei.attackedBy[Us][ALL_PIECES]; + // If there aren't enemy attacks huge bonus, a bit smaller if at // least block square is not attacked, otherwise smallest bonus. int k = !unsafeSquares ? 15 : !(unsafeSquares & blockSq) ? 9 : 3; @@ -1089,9 +1093,9 @@ Value do_evaluate(const Position& pos, Value& margin) { assert(eg_value(v) > -VALUE_INFINITE && eg_value(v) < VALUE_INFINITE); assert(ph >= PHASE_ENDGAME && ph <= PHASE_MIDGAME); - int ev = (eg_value(v) * int(sf)) / SCALE_FACTOR_NORMAL; - int result = (mg_value(v) * int(ph) + ev * int(128 - ph)) / 128; - return Value((result / GrainSize) * GrainSize); // Sign independent + int e = (eg_value(v) * int(sf)) / SCALE_FACTOR_NORMAL; + int r = (mg_value(v) * int(ph) + e * int(PHASE_MIDGAME - ph)) / PHASE_MIDGAME; + return Value((r / GrainSize) * GrainSize); // Sign independent } // apply_weight() weights score v by score w trying to prevent overflow