]> git.sesse.net Git - stockfish/commitdiff
Non-linear bonus for pawn count
authorGuardianRM <strimr25@mail.ru>
Sun, 12 Aug 2018 16:40:03 +0000 (18:40 +0200)
committerStéphane Nicolet <cassio@free.fr>
Sun, 12 Aug 2018 16:40:11 +0000 (18:40 +0200)
This patch introduces a non-linear bonus for pawns, along with some
(linear) corrections for the other pieces types.

The original values were obtained by a massive non-linear tuning of both
pawns and other pieces by GuardianRM, while Alain Savard and Chris Cain
later simplified the patch by observing that, apart from the pawn case, the
tuned corrections were in fact almost affine and could be incorporated in
our current code base via the piece values in types.h (offset) and the diagonal
of the quadratic matrix (slope). See discussion in PR#1725 :
https://github.com/official-stockfish/Stockfish/pull/1725

STC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 42948 W: 9662 L: 9317 D: 23969
http://tests.stockfishchess.org/tests/view/5b6ff6e60ebc5902bdba1d87

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 19683 W: 3409 L: 3206 D: 13068
http://tests.stockfishchess.org/tests/view/5b702dbd0ebc5902bdba216b

How to continue from there?
- Maybe the non-linearity for the pawn value could be somewhat tempered
  again and a simpler linear correction for pawns would work?

Closes https://github.com/official-stockfish/Stockfish/pull/1734

Bench: 4681496

AUTHORS
src/material.cpp
src/search.cpp
src/types.h

diff --git a/AUTHORS b/AUTHORS
index 029109acd512a8ad29fbde9b8fd5b7cd932fc64a..9c25509b249bf1c476ee2d099448b188e47e1414 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -45,6 +45,7 @@ Gian-Carlo Pascutto (gcp)
 Gontran Lemaire (gonlem)
 Goodkov Vasiliy Aleksandrovich (goodkov)
 Gregor Cramer
+GuardianRM
 Günther Demetz (pb00067, pb00068)
 Guy Vreuls (gvreuls)
 Henri Wiechers
index 64a5bff033f9e7579fa33c9c94c3ea3f9dec0b22..d98eb125e4bb5f84c8ebda36b1d146b20f5fdb41 100644 (file)
@@ -34,11 +34,11 @@ namespace {
   constexpr int QuadraticOurs[][PIECE_TYPE_NB] = {
     //            OUR PIECES
     // pair pawn knight bishop rook queen
-    {1667                               }, // Bishop pair
+    {1443                               }, // Bishop pair
     {  40,    0                         }, // Pawn
-    {  32,  255,  -3                    }, // Knight      OUR PIECES
+    {  32,  255, -67                    }, // Knight      OUR PIECES
     {   0,  104,   4,    0              }, // Bishop
-    { -26,   -2,  47,   105,  -149      }, // Rook
+    { -26,   -2,  47,   105,  -221      }, // Rook
     {-189,   24, 117,   133,  -134, -10 }  // Queen
   };
 
@@ -53,6 +53,8 @@ namespace {
     {  97,  100, -42,   137,  268,    0 }  // Queen
   };
 
+  constexpr int PawnCount[] = { 0, 304,  144, -320, -560, -704, -672, -464, -320 };
+
   // Endgame evaluation and scaling functions are accessed directly and not through
   // the function maps because they correspond to more than one material hash key.
   Endgame<KXK>    EvaluateKXK[] = { Endgame<KXK>(WHITE),    Endgame<KXK>(BLACK) };
@@ -89,7 +91,7 @@ namespace {
 
     constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
 
-    int bonus = 0;
+    int bonus = PawnCount[pieceCount[Us][PAWN]];
 
     // Second-degree polynomial material imbalance, by Tord Romstad
     for (int pt1 = NO_PIECE_TYPE; pt1 <= QUEEN; ++pt1)
index 0f27564a1053513b392b117a34303abe88db3a12..b34d4ae7c108abfb2040a1dac2eb2da8bff632e1 100644 (file)
@@ -258,7 +258,7 @@ void MainThread::search() {
 
       // Vote according to score and depth
       for (Thread* th : Threads)
-          votes[th->rootMoves[0].pv[0]] +=  int(th->rootMoves[0].score - minScore)  
+          votes[th->rootMoves[0].pv[0]] +=  int(th->rootMoves[0].score - minScore)
                                           + int(th->completedDepth);
 
       // Select best thread
index 43e9fbff471502b69b256f6742944f23d251f190..fdf7ba93dc63a017ce136b369d79b891b3dfb8d8 100644 (file)
@@ -183,10 +183,10 @@ enum Value : int {
   VALUE_MATED_IN_MAX_PLY = -VALUE_MATE + 2 * MAX_PLY,
 
   PawnValueMg   = 175,   PawnValueEg   = 240,
-  KnightValueMg = 764,   KnightValueEg = 848,
-  BishopValueMg = 815,   BishopValueEg = 905,
-  RookValueMg   = 1282,  RookValueEg   = 1373,
-  QueenValueMg  = 2500,  QueenValueEg  = 2670,
+  KnightValueMg = 784,   KnightValueEg = 868,
+  BishopValueMg = 831,   BishopValueEg = 919,
+  RookValueMg   = 1286,  RookValueEg   = 1378,
+  QueenValueMg  = 2527,  QueenValueEg  = 2697,
 
   MidgameLimit  = 15258, EndgameLimit  = 3915
 };