]> git.sesse.net Git - stockfish/commitdiff
Use bool(Bitboard b) instead of !!b (#1321)
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 3 Dec 2017 17:29:55 +0000 (18:29 +0100)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Sun, 3 Dec 2017 17:29:55 +0000 (18:29 +0100)
The idiom !!b is confusing newcomers (e.g. Stefan needs explaining here https://groups.google.com/d/msg/fishcooking/vYqnsRI4brY/Gaf60QuACwAJ).

No functional change.

src/bitboard.h
src/evaluate.cpp
src/pawns.cpp
src/pawns.h
src/search.cpp

index ba1b0072bce5079064b5f59cbe26328cb7b6dc03..05f65931cb3e20bfbc810e9272f51816c9f6109e 100644 (file)
@@ -130,7 +130,6 @@ constexpr bool more_than_one(Bitboard b) {
   return b & (b - 1);
 }
 
-
 /// rank_bb() and file_bb() return a bitboard representing all the squares on
 /// the given file or rank.
 
index e10618494cc1c87a1af02a64909be59af6c78b16..e470e61350ca268fdced0c37e8b186448aed535b 100644 (file)
@@ -342,12 +342,12 @@ namespace {
             // Bonus for outpost squares
             bb = OutpostRanks & ~pe->pawn_attacks_span(Them);
             if (bb & s)
-                score += Outpost[Pt == BISHOP][!!(attackedBy[Us][PAWN] & s)] * 2;
+                score += Outpost[Pt == BISHOP][bool(attackedBy[Us][PAWN] & s)] * 2;
             else
             {
                 bb &= b & ~pos.pieces(Us);
                 if (bb)
-                   score += Outpost[Pt == BISHOP][!!(attackedBy[Us][PAWN] & bb)];
+                   score += Outpost[Pt == BISHOP][bool(attackedBy[Us][PAWN] & bb)];
             }
 
             // Bonus when behind a pawn
@@ -388,7 +388,7 @@ namespace {
 
             // Bonus when on an open or semi-open file
             if (pe->semiopen_file(Us, file_of(s)))
-                score += RookOnFile[!!pe->semiopen_file(Them, file_of(s))];
+                score += RookOnFile[bool(pe->semiopen_file(Them, file_of(s)))];
 
             // Penalty when trapped by the king, even more if the king cannot castle
             else if (mob <= 3)
@@ -450,7 +450,7 @@ namespace {
         kingDanger =        kingAttackersCount[Them] * kingAttackersWeight[Them]
                     + 102 * kingAdjacentZoneAttacksCount[Them]
                     + 191 * popcount(kingRing[Us] & weak)
-                    + 143 * !!pos.pinned_pieces(Us)
+                    + 143 * bool(pos.pinned_pieces(Us))
                     - 848 * !pos.count<QUEEN>(Them)
                     -   9 * mg_value(score) / 8
                     +  40;
index 9099875420f821bd73b795cd76e4f449a02df9ec..a031534d3a4fd9b75d44e8c69ac97f99d8ef9c28 100644 (file)
@@ -174,7 +174,7 @@ namespace {
 
         // Score this pawn
         if (supported | phalanx)
-            score += Connected[opposed][!!phalanx][popcount(supported)][relative_rank(Us, s)];
+            score += Connected[opposed][bool(phalanx)][popcount(supported)][relative_rank(Us, s)];
 
         else if (!neighbours)
             score -= Isolated, e->weakUnopposed[Us] += !opposed;
index 1981529337c5627d3770ced65e98c213c7f69124..a018f2c17dc6b8bf41a0e5ce5eeee5383208487a 100644 (file)
@@ -50,7 +50,7 @@ struct Entry {
   }
 
   int pawns_on_same_color_squares(Color c, Square s) const {
-    return pawnsOnSquares[c][!!(DarkSquares & s)];
+    return pawnsOnSquares[c][bool(DarkSquares & s)];
   }
 
   template<Color Us>
index 6917a0f753d0c309ab6f7d113b2cab6cb3a9841f..b6a494422a468315f4cb9cd31a9e2e004109345d 100644 (file)
@@ -1115,7 +1115,7 @@ moves_loop: // When in check search starts from here
 
     const bool PvNode = NT == PV;
 
-    assert(InCheck == !!pos.checkers());
+    assert(InCheck == bool(pos.checkers()));
     assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
     assert(PvNode || (alpha == beta - 1));
     assert(depth <= DEPTH_ZERO);