X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=94ec2b6c04162f8ba7c3e9e08395f4942993c88b;hp=fe4eef57493c8ed3a601120dc7fee3233e7a1b5d;hb=02606a8c8360782c5c14e6a76fd7867f2cb9552d;hpb=0958e5c6d346d1fac5fbae5e12762a48c6d24a2a diff --git a/src/evaluate.cpp b/src/evaluate.cpp index fe4eef57..94ec2b6c 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -677,8 +677,7 @@ Value do_evaluate(const Position& pos, Value& margin) { Score score = SCORE_ZERO; // Undefended minors get penalized even if not under attack - undefendedMinors = pos.pieces(Them) - & (pos.pieces(BISHOP) | pos.pieces(KNIGHT)) + undefendedMinors = pos.pieces(Them, BISHOP, KNIGHT) & ~ei.attackedBy[Them][ALL_PIECES]; if (undefendedMinors) @@ -900,16 +899,30 @@ Value do_evaluate(const Position& pos, Value& margin) { else unsafeSquares = squaresToQueen & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them)); - // If there aren't enemy attacks or pieces along the path to queen give - // huge bonus. Even bigger if we protect the pawn's path. - if (!unsafeSquares) - ebonus += Value(rr * (squaresToQueen == defendedSquares ? 17 : 15)); - else - // OK, there are enemy attacks or pieces (but not pawns). Are those - // squares which are attacked by the enemy also attacked by us ? - // If yes, big bonus (but smaller than when there are no enemy attacks), - // if no, somewhat smaller bonus. - ebonus += Value(rr * ((unsafeSquares & defendedSquares) == unsafeSquares ? 13 : 8)); + // Default bonus for the empty square in front + int bonusMultiplier = 3; + + if ((defendedSquares & SquareBB[blockSq]) != 0) + { + // Defending the square in front + bonusMultiplier += 2; + if ((unsafeSquares & defendedSquares) == unsafeSquares) + // Defending all the attacked squares + // bigger bonus if we are defending everything + bonusMultiplier += (squaresToQueen == defendedSquares) ? 4 : 2; + } + + if ((unsafeSquares & SquareBB[blockSq]) == 0) + { + // The square infront isn't attacked + bonusMultiplier += 6; + if (!unsafeSquares) + bonusMultiplier += 6; + } + + Value bonus = Value(rr * bonusMultiplier); + ebonus += bonus; + mbonus += bonus; } } // rr != 0