From: Ralph Stößer Date: Thu, 31 Oct 2013 05:02:17 +0000 (+0100) Subject: Use a formula for chain membership bonus X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=e8f9447b11efd80a01733175c5076db988c45aa9 Use a formula for chain membership bonus 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 --- diff --git a/src/main.cpp b/src/main.cpp index 74483a87..c0a9a348 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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"]); diff --git a/src/pawns.cpp b/src/pawns.cpp index c8c2e6d8..91da8a7b 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -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. diff --git a/src/pawns.h b/src/pawns.h index 0098a963..f6be84e7 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -73,6 +73,7 @@ struct Entry { typedef HashTable Table; +void init(); Entry* probe(const Position& pos, Table& entries); }