]> git.sesse.net Git - stockfish/blobdiff - src/pawns.cpp
Move time related global variables under TimeManager
[stockfish] / src / pawns.cpp
index 8835d327e068b1e12215cfe754d3e17bcd641970..b5c377efcd1e30221a514ea050e8787ba8b5a692 100644 (file)
@@ -148,7 +148,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const {
   assert(pos.is_ok());
 
   Key key = pos.get_pawn_key();
-  int index = int(key & (size - 1));
+  unsigned index = unsigned(key & (size - 1));
   PawnInfo* pi = entries + index;
 
   // If pi->key matches the position's pawn hash key, it means that we
@@ -214,7 +214,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
       pi->qsStormValue[Us] += QStormTable[relative_square(Us, s)] + bonus;
 
       // Our rank plus previous one. Used for chain detection.
-      b = rank_bb(r) | rank_bb(r + (Us == WHITE ? -1 : 1));
+      b = rank_bb(r) | rank_bb(Us == WHITE ? r - 1 : r + 1);
 
       // Passed, isolated, doubled or member of a pawn
       // chain (but not the backward one) ?
@@ -226,15 +226,15 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
 
       // Test for backward pawn
       //
+      backward = false;
+
       // If the pawn is passed, isolated, or member of a pawn chain
       // it cannot be backward. If can capture an enemy pawn or if
       // there are friendly pawns behind on neighboring files it cannot
       // be backward either.
-      if (   (passed | isolated | chain)
-          || (ourPawns & attack_span_mask(opposite_color(Us), s))
-          || (pos.attacks_from<PAWN>(s, Us) & theirPawns))
-          backward = false;
-      else
+      if (   !(passed | isolated | chain)
+          && !(ourPawns & attack_span_mask(opposite_color(Us), s))
+          && !(pos.attacks_from<PAWN>(s, Us) & theirPawns))
       {
           // We now know that there are no friendly pawns beside or behind this
           // pawn on neighboring files. We now check whether the pawn is
@@ -274,7 +274,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
       if (isolated)
       {
           value -= IsolatedPawnPenalty[f];
-          if (!(theirPawns & file_bb(f)))
+          if (!opposed)
               value -= IsolatedPawnPenalty[f] / 2;
       }
       if (doubled)
@@ -283,7 +283,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
       if (backward)
       {
           value -= BackwardPawnPenalty[f];
-          if (!(theirPawns & file_bb(f)))
+          if (!opposed)
               value -= BackwardPawnPenalty[f] / 2;
       }
       if (chain)