]> git.sesse.net Git - stockfish/commitdiff
First check threshold in space evaluation
authorStefano Cardanobile <stefano.cardanobile@gmail.com>
Wed, 8 Aug 2018 12:27:28 +0000 (14:27 +0200)
committerStéphane Nicolet <cassio@free.fr>
Wed, 8 Aug 2018 15:58:41 +0000 (17:58 +0200)
Currently, we first calculate some bitboards at the top of Evaluation::space()
and then check whether we actually need them. Invert the ordering. Of course this
does not make a difference in current master because the constexpr bitboard
calculations are in fact done at compile time by any decent compiler, but I find
my version a bit healthier since it will always meet or exceed current implementation
even if we eventually change the spaceMask to something not contsexpr.

No functional change.

src/evaluate.cpp

index c54b6d30bc81eed71e2582bfa7704cfc1da34739..9eebad9e5b3f434ffe9dec8d5971be8c96db699d 100644 (file)
@@ -718,14 +718,14 @@ namespace {
   template<Tracing T> template<Color Us>
   Score Evaluation<T>::space() const {
 
+    if (pos.non_pawn_material() < SpaceThreshold)
+        return SCORE_ZERO;
+
     constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
     constexpr Bitboard SpaceMask =
       Us == WHITE ? CenterFiles & (Rank2BB | Rank3BB | Rank4BB)
                   : CenterFiles & (Rank7BB | Rank6BB | Rank5BB);
 
-    if (pos.non_pawn_material() < SpaceThreshold)
-        return SCORE_ZERO;
-
     // Find the available squares for our pieces inside the area defined by SpaceMask
     Bitboard safe =   SpaceMask
                    & ~pos.pieces(Us, PAWN)