From eefbe967c2a1ea1f1e39e5cfff1c38e451a9be2e Mon Sep 17 00:00:00 2001 From: snicolet Date: Sun, 19 Feb 2017 14:25:05 -0800 Subject: [PATCH] Keep pawns on both flanks Positions with pawns on only one flank tend to be more drawish. We add a term to the initiative bonus to help the attacking player keep pawns on both flanks. STC: yellowish run stopped after 257137 games LLR: -0.92 (-2.94,2.94) [0.00,5.00] Total: 257137 W: 46560 L: 45511 D: 165066 LTC: LLR: 2.95 (-2.94,2.94) [0.00,5.00] Total: 15602 W: 2125 L: 1956 D: 11521 Bench : 6976310 Closes #1009 --- src/evaluate.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 62620a77..6180c482 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -377,11 +377,12 @@ namespace { // evaluate_king() assigns bonuses and penalties to a king of a given color + const Bitboard QueenSide = FileABB | FileBBB | FileCBB | FileDBB; const Bitboard CenterFiles = FileCBB | FileDBB | FileEBB | FileFBB; + const Bitboard KingSide = FileEBB | FileFBB | FileGBB | FileHBB; const Bitboard KingFlank[FILE_NB] = { - CenterFiles >> 2, CenterFiles >> 2, CenterFiles >> 2, CenterFiles, CenterFiles, - CenterFiles << 2, CenterFiles << 2, CenterFiles << 2 + QueenSide, QueenSide, QueenSide, CenterFiles, CenterFiles, KingSide, KingSide, KingSide }; template @@ -724,14 +725,15 @@ namespace { int kingDistance = distance(pos.square(WHITE), pos.square(BLACK)) - distance(pos.square(WHITE), pos.square(BLACK)); int pawns = pos.count(WHITE) + pos.count(BLACK); + bool bothFlanks = (pos.pieces(PAWN) & QueenSide) && (pos.pieces(PAWN) & KingSide); // Compute the initiative bonus for the attacking side - int initiative = 8 * (asymmetry + kingDistance - 15) + 12 * pawns; + int initiative = 8 * (asymmetry + kingDistance - 17) + 12 * pawns + 16 * bothFlanks; // Now apply the bonus: note that we find the attacking side by extracting // the sign of the endgame value, and that we carefully cap the bonus so - // that the endgame score will never be divided by more than two. - int value = ((eg > 0) - (eg < 0)) * std::max(initiative, -abs(eg / 2)); + // that the endgame score will never change sign after the bonus. + int value = ((eg > 0) - (eg < 0)) * std::max(initiative, -abs(eg)); return make_score(0, value); } -- 2.39.2