Skip to content

Commit 452e515

Browse files
snicoletmcostalba
authored andcommitted
Good bishops on the main diagonals
Bonus in midgame for bishops on long diagonals when the central squares are not occupied by pawns. Author: ElbertoOne Passed STC: LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 10801 W: 1955 L: 1786 D: 7060 http://tests.stockfishchess.org/tests/view/59cf5c1d0ebc5916ff64b9da and LTC: LLR: 2.97 (-2.94,2.94) [0.00,5.00] Total: 83978 W: 10685 L: 10303 D: 62990 http://tests.stockfishchess.org/tests/view/59cf6f6c0ebc5916ff64b9e4 Bench: 5620312
1 parent 07b5a28 commit 452e515

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/evaluate.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131

3232
namespace {
3333

34+
const Bitboard LongDiagonals = 0x8142241818244281ULL; // A1..H8 | H1..A8
35+
const Bitboard Center = (FileDBB | FileEBB) & (Rank4BB | Rank5BB);
36+
const Bitboard QueenSide = FileABB | FileBBB | FileCBB | FileDBB;
37+
const Bitboard CenterFiles = FileCBB | FileDBB | FileEBB | FileFBB;
38+
const Bitboard KingSide = FileEBB | FileFBB | FileGBB | FileHBB;
39+
40+
const Bitboard KingFlank[FILE_NB] = {
41+
QueenSide, QueenSide, QueenSide, CenterFiles, CenterFiles, KingSide, KingSide, KingSide
42+
};
43+
3444
namespace Trace {
3545

3646
enum Tracing {NO_TRACE, TRACE};
@@ -204,6 +214,7 @@ namespace {
204214
// Assorted bonuses and penalties used by evaluation
205215
const Score MinorBehindPawn = S( 16, 0);
206216
const Score BishopPawns = S( 8, 12);
217+
const Score LongRangedBishop = S( 22, 0);
207218
const Score RookOnPawn = S( 8, 24);
208219
const Score TrappedRook = S( 92, 0);
209220
const Score WeakQueen = S( 50, 10);
@@ -338,10 +349,18 @@ namespace {
338349
&& (pos.pieces(PAWN) & (s + pawn_push(Us))))
339350
score += MinorBehindPawn;
340351

341-
// Penalty for pawns on the same color square as the bishop
342352
if (Pt == BISHOP)
353+
{
354+
// Penalty for pawns on the same color square as the bishop
343355
score -= BishopPawns * pe->pawns_on_same_color_squares(Us, s);
344356

357+
// Bonus for bishop on a long diagonal without pawns in the center
358+
if ( (LongDiagonals & s)
359+
&& !(attackedBy[Them][PAWN] & s)
360+
&& !(Center & PseudoAttacks[BISHOP][s] & pos.pieces(PAWN)))
361+
score += LongRangedBishop;
362+
}
363+
345364
// An important Chess960 pattern: A cornered bishop blocked by a friendly
346365
// pawn diagonally in front of it is a very serious problem, especially
347366
// when that pawn is also blocked.
@@ -396,14 +415,6 @@ namespace {
396415

397416
// evaluate_king() assigns bonuses and penalties to a king of a given color
398417

399-
const Bitboard QueenSide = FileABB | FileBBB | FileCBB | FileDBB;
400-
const Bitboard CenterFiles = FileCBB | FileDBB | FileEBB | FileFBB;
401-
const Bitboard KingSide = FileEBB | FileFBB | FileGBB | FileHBB;
402-
403-
const Bitboard KingFlank[FILE_NB] = {
404-
QueenSide, QueenSide, QueenSide, CenterFiles, CenterFiles, KingSide, KingSide, KingSide
405-
};
406-
407418
template<Tracing T> template<Color Us>
408419
Score Evaluation<T>::evaluate_king() {
409420

0 commit comments

Comments
 (0)