]> git.sesse.net Git - stockfish/commitdiff
Use a formula for chain membership bonus
authorRalph Stößer <ralph.stoesser@ralph_stoesser.(none)>
Thu, 31 Oct 2013 05:02:17 +0000 (06:02 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 31 Oct 2013 05:13:30 +0000 (06:13 +0100)
Passed both short TC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 5087 W: 1072 L: 951 D: 3064

And long TC:
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 28620 W: 5042 L: 4798 D: 18780

bench: 7995098

src/main.cpp
src/pawns.cpp
src/pawns.h

index 74483a87ed29d010132007b4c2beabeec40023e5..c0a9a348b3d0a16cb5cb0f69e44e8cc1405c8799 100644 (file)
@@ -37,6 +37,7 @@ int main(int argc, char* argv[]) {
   Position::init();
   Bitbases::init_kpk();
   Search::init();
+  Pawns::init();
   Eval::init();
   Threads.init();
   TT.set_size(Options["Hash"]);
index c8c2e6d8c243db77d67b30afd109dfd2ea1fff4f..91da8a7b0858cf748e7ba57231aabfa93b6f238a 100644 (file)
@@ -51,16 +51,8 @@ namespace {
   { S(20, 28), S(29, 31), S(33, 31), S(33, 31),
     S(33, 31), S(33, 31), S(29, 31), S(20, 28) }};
 
-  // Pawn chain membership bonus by file
-  const Score ChainMember[FILE_NB][RANK_NB] = {
-  { S(0, 0), S(14, 0), S(16, 4), S(18,  9), S(28, 28), S(52, 104), S(118, 236) },
-  { S(0, 0), S(16, 0), S(18, 5), S(20, 10), S(30, 30), S(54, 108), S(120, 240) },
-  { S(0, 0), S(16, 0), S(18, 5), S(20, 10), S(30, 30), S(54, 108), S(120, 240) },
-  { S(0, 0), S(17, 0), S(19, 6), S(22, 11), S(33, 33), S(59, 118), S(127, 254) },
-  { S(0, 0), S(17, 0), S(19, 6), S(22, 11), S(33, 33), S(59, 118), S(127, 254) },
-  { S(0, 0), S(16, 0), S(18, 5), S(20, 10), S(30, 30), S(54, 108), S(120, 240) },
-  { S(0, 0), S(16, 0), S(18, 5), S(20, 10), S(30, 30), S(54, 108), S(120, 240) },
-  { S(0, 0), S(14, 0), S(16, 4), S(18,  9), S(28, 28), S(52, 104), S(118, 236) }};
+  // Pawn chain membership bonus by file and rank (initialized by formula)
+  Score ChainMember[FILE_NB][RANK_NB];
 
   // Candidate passed pawn bonus by rank
   const Score CandidatePassed[RANK_NB] = {
@@ -199,6 +191,22 @@ namespace {
 
 namespace Pawns {
 
+/// init() initializes some tables by formula instead of hard-code their values
+
+void init() {
+
+  const int chainByFile[8] = { 1, 3, 3, 4, 4, 3, 3, 1 };
+  int bonus;
+
+  for (Rank r = RANK_1; r < RANK_8; ++r)
+      for (File f = FILE_A; f <= FILE_H; ++f)
+      {
+          bonus = r * (r-1) * (r-2) + chainByFile[f] * (r/2 + 1);
+          ChainMember[f][r] = make_score(bonus, bonus);
+      }
+}
+
+
 /// probe() takes a position object as input, computes a Entry object, and returns
 /// a pointer to it. The result is also stored in a hash table, so we don't have
 /// to recompute everything when the same pawn structure occurs again.
index 0098a963db224a478d74eed4164d24acb5ffebad..f6be84e774ed122d86cd8d8be9a351c64bc1340b 100644 (file)
@@ -73,6 +73,7 @@ struct Entry {
 
 typedef HashTable<Entry, 16384> Table;
 
+void init();
 Entry* probe(const Position& pos, Table& entries);
 
 }