From: Tord Romstad Date: Mon, 3 Jan 2011 21:32:57 +0000 (+0100) Subject: Reintroduce the old "trapped bishop in the corner" evaluation term X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=d5f2e32b5c2bba5056df7804704f14af0977a8ed Reintroduce the old "trapped bishop in the corner" evaluation term for Chess960 games. After 1918 games at 30" Mod - Orig: 1052-866 (+532,-346,=1040), Elo +33.8 --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 2a80568d..58feae39 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -168,6 +168,11 @@ namespace { // right to castle. const Value TrappedRookPenalty = Value(180); + // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by + // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only + // happen in Chess960 games. + const Score TrappedBishopA1H1Penalty = make_score(100, 100); + // The SpaceMask[Color] contains the area of the board which is considered // by the space evaluation. In the middle game, each side is given a bonus // based on how many squares inside this area are safe and available for @@ -556,6 +561,28 @@ namespace { bonus += (Piece == ROOK ? RookOn7thBonus : QueenOn7thBonus); } + // Special extra evaluation for bishops + if (Piece == BISHOP) + { + // An important Chess960 pattern: A cornered bishop blocked by + // a friendly pawn diagonally in front of it is a very serious + // problem, especially when that pawn is also blocked. + if (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1)) + { + SquareDelta d = pawn_push(Us) + + (square_file(s) == FILE_A ? DELTA_E : DELTA_W); + if (pos.piece_on(s + d) == piece_of_color_and_type(Us, PAWN)) + { + if (!pos.square_is_empty(s + d + pawn_push(Us))) + bonus -= 2*TrappedBishopA1H1Penalty; + else if (pos.piece_on(s + 2*d) == piece_of_color_and_type(Us, PAWN)) + bonus -= TrappedBishopA1H1Penalty; + else + bonus -= TrappedBishopA1H1Penalty / 2; + } + } + } + // Special extra evaluation for rooks if (Piece == ROOK) {