X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fpawns.cpp;h=3ad88fb206aa011ece4fb6dca4c75acf17edb758;hb=1cc42ac9e4786790a30d2b9dd572dc7e7bfcd021;hp=997aa2148815142da303cab5acb499bd78d0d6e9;hpb=2f1935078da225c90f7887ed8c345cc7baebcfcc;p=stockfish diff --git a/src/pawns.cpp b/src/pawns.cpp index 997aa214..3ad88fb2 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -61,7 +61,14 @@ namespace { S(34,68), S(83,166), S(0, 0), S( 0, 0) }; + const Score PawnStructureWeight = S(233, 201); + #undef S + + inline Score apply_weight(Score v, Score w) { + return make_score((int(mg_value(v)) * mg_value(w)) / 0x100, + (int(eg_value(v)) * eg_value(w)) / 0x100); + } } @@ -75,7 +82,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const { assert(pos.is_ok()); Key key = pos.get_pawn_key(); - PawnInfo* pi = find(key); + PawnInfo* pi = probe(key); // If pi->key matches the position's pawn hash key, it means that we // have analysed this pawn structure before, and we can simply return @@ -95,9 +102,12 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const { pi->pawnAttacks[WHITE] = ((wPawns << 9) & ~FileABB) | ((wPawns << 7) & ~FileHBB); pi->pawnAttacks[BLACK] = ((bPawns >> 7) & ~FileABB) | ((bPawns >> 9) & ~FileHBB); - // Evaluate pawns for both colors + // Evaluate pawns for both colors and weight the result pi->value = evaluate_pawns(pos, wPawns, bPawns, pi) - evaluate_pawns(pos, bPawns, wPawns, pi); + + pi->value = apply_weight(pi->value, PawnStructureWeight); + return pi; } @@ -106,7 +116,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const { template Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, - Bitboard theirPawns, PawnInfo* pi) const { + Bitboard theirPawns, PawnInfo* pi) { const BitCountType Max15 = CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15; const Color Them = (Us == WHITE ? BLACK : WHITE);