]> git.sesse.net Git - stockfish/blobdiff - src/pawns.cpp
Promotion piece must be empty if is not a promotion
[stockfish] / src / pawns.cpp
index 997aa2148815142da303cab5acb499bd78d0d6e9..3ad88fb206aa011ece4fb6dca4c75acf17edb758 100644 (file)
@@ -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<WHITE>(pos, wPawns, bPawns, pi)
              - evaluate_pawns<BLACK>(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<Color Us>
 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);