X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=523ed15725001933556a20b195573ddcd5143e4e;hp=d8d8243fc9570ab08b1cb7233544fabd7e8e61cf;hb=8a7876d48d4360d14d918c1ff444b5d6eb0382de;hpb=91de6b0f37516462658f6e38db430813aa9e7ed8 diff --git a/src/pawns.cpp b/src/pawns.cpp index d8d8243f..523ed157 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -58,7 +58,7 @@ namespace { S(20,20), S(40,40), S(0, 0), S(0, 0) }; // Bonus for file distance of the two outermost pawns - const Score PawnsFileSpan = S(0, 15); + const Score PawnsFileSpan = S(0, 8); // Unsupported pawn penalty const Score UnsupportedPawnPenalty = S(20, 10); @@ -194,19 +194,24 @@ namespace { namespace Pawns { +/// init() initializes some tables used by evaluation. Instead of hard-coded +/// tables, when makes sense, we prefer to calculate them with a formula to +/// reduce independent parameters and to allow easier tuning and better insight. + void init() { - const int c[RANK_NB] = {0, 6, 15, 10, 57, 75, 135, 258}; + static const int Seed[RANK_NB] = { 0, 6, 15, 10, 57, 75, 135, 258 }; - for (Rank r = RANK_2; r <= RANK_7; ++r) - for (int opposed = false; opposed <= true; ++opposed) - for (int phalanx = false; phalanx <= true; ++phalanx) + for (int opposed = 0; opposed <= 1; ++opposed) + for (int phalanx = 0; phalanx <= 1; ++phalanx) + for (Rank r = RANK_2; r < RANK_8; ++r) { - int bonus = c[r] + (phalanx ? (c[r + 1] - c[r]) / 2 : 0); + int bonus = Seed[r] + (phalanx ? (Seed[r + 1] - Seed[r]) / 2 : 0); Connected[opposed][phalanx][r] = make_score(bonus / 2, bonus >> opposed); } } + /// probe() takes a position 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.