Skip to content

Commit bd4d2b0

Browse files
Stefano80snicolet
authored andcommitted
First check threshold in space evaluation
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.
1 parent c569cf2 commit bd4d2b0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/evaluate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,14 @@ namespace {
718718
template<Tracing T> template<Color Us>
719719
Score Evaluation<T>::space() const {
720720

721+
if (pos.non_pawn_material() < SpaceThreshold)
722+
return SCORE_ZERO;
723+
721724
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
722725
constexpr Bitboard SpaceMask =
723726
Us == WHITE ? CenterFiles & (Rank2BB | Rank3BB | Rank4BB)
724727
: CenterFiles & (Rank7BB | Rank6BB | Rank5BB);
725728

726-
if (pos.non_pawn_material() < SpaceThreshold)
727-
return SCORE_ZERO;
728-
729729
// Find the available squares for our pieces inside the area defined by SpaceMask
730730
Bitboard safe = SpaceMask
731731
& ~pos.pieces(Us, PAWN)

0 commit comments

Comments
 (0)