1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

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
This commit is contained in:
snicolet 2017-02-19 14:25:05 -08:00 committed by Joona Kiiski
parent c243cd5f4a
commit eefbe967c2

View file

@ -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<Color Us, bool DoTrace>
@ -724,14 +725,15 @@ namespace {
int kingDistance = distance<File>(pos.square<KING>(WHITE), pos.square<KING>(BLACK))
- distance<Rank>(pos.square<KING>(WHITE), pos.square<KING>(BLACK));
int pawns = pos.count<PAWN>(WHITE) + pos.count<PAWN>(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);
}