]> git.sesse.net Git - stockfish/commitdiff
Space bonus in presence of open files
authorStéphane Nicolet <cassio@free.fr>
Fri, 2 Sep 2016 22:04:20 +0000 (00:04 +0200)
committerStéphane Nicolet <cassio@free.fr>
Fri, 2 Sep 2016 22:04:20 +0000 (00:04 +0200)
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
src/pawns.cpp
src/pawns.h

index d533eed8c76d17172c10632c2c0cdada03a5a7a6..35764b717207e38b3871f367d4edbe5c400f8fc6 100644 (file)
@@ -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<ALL_PIECES>(Us);
+    int weight = pos.count<ALL_PIECES>(Us) - 2 * ei.pi->open_files();
 
-    return make_score(bonus * weight * weight / 22, 0);
+    return make_score(bonus * weight * weight / 18, 0);
   }
 
 
index 72496fcc26ad5cf7b3844a48a6daf20388ae2c87..b83b780ab00f21e8228889e8ea13c358d0ce2939 100644 (file)
@@ -215,6 +215,7 @@ Entry* probe(const Position& pos) {
   e->key = key;
   e->score = evaluate<WHITE>(pos, e) - evaluate<BLACK>(pos, e);
   e->asymmetry = popcount(e->semiopenFiles[WHITE] ^ e->semiopenFiles[BLACK]);
+  e->openFiles = popcount(e->semiopenFiles[WHITE] & e->semiopenFiles[BLACK]);
   return e;
 }
 
index 24843e30618074dd8cf1f990dc834ff6ab17e86b..e26ae67e0f9146d4de45f0ed9526a904404f1617 100644 (file)
@@ -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<Entry, 16384> Table;