From d37dfe9ae41de722eccd50aee39fb5eb59811bc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Nicolet?= Date: Sat, 3 Sep 2016 00:04:20 +0200 Subject: [PATCH] Space bonus in presence of open files MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the opponent has a cramped position, opening a file often helps him/her to exchange pieces, so it makes sense to reduce the space bonus if there are open files. Credits: Leonardo Ljubičić for the strategic idea, Alain Savard for the implementation of the open files calculation, "CrunchyNYC" for the compensation of the numerator. STC: LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 49112 W: 9239 L: 8900 D: 30973 LTC: LLR: 2.95 (-2.94,2.94) [0.00,5.00] Total: 89415 W: 12014 L: 11601 D: 65800 Bench: 7591630 --- src/evaluate.cpp | 4 ++-- src/pawns.cpp | 1 + src/pawns.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index d533eed8..35764b71 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -706,9 +706,9 @@ namespace { // ...count safe + (behind & safe) with a single popcount int bonus = popcount((Us == WHITE ? safe << 32 : safe >> 32) | (behind & safe)); bonus = std::min(16, bonus); - int weight = pos.count(Us); + int weight = pos.count(Us) - 2 * ei.pi->open_files(); - return make_score(bonus * weight * weight / 22, 0); + return make_score(bonus * weight * weight / 18, 0); } diff --git a/src/pawns.cpp b/src/pawns.cpp index 72496fcc..b83b780a 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -215,6 +215,7 @@ Entry* probe(const Position& pos) { e->key = key; e->score = evaluate(pos, e) - evaluate(pos, e); e->asymmetry = popcount(e->semiopenFiles[WHITE] ^ e->semiopenFiles[BLACK]); + e->openFiles = popcount(e->semiopenFiles[WHITE] & e->semiopenFiles[BLACK]); return e; } diff --git a/src/pawns.h b/src/pawns.h index 24843e30..e26ae67e 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -38,6 +38,7 @@ struct Entry { Bitboard passed_pawns(Color c) const { return passedPawns[c]; } Bitboard pawn_attacks_span(Color c) const { return pawnAttacksSpan[c]; } int pawn_asymmetry() const { return asymmetry; } + int open_files() const { return openFiles; } int semiopen_file(Color c, File f) const { return semiopenFiles[c] & (1 << f); @@ -74,6 +75,7 @@ struct Entry { int semiopenFiles[COLOR_NB]; int pawnsOnSquares[COLOR_NB][COLOR_NB]; // [color][light/dark squares] int asymmetry; + int openFiles; }; typedef HashTable Table; -- 2.39.2