From 602d7fbb07e2cb1643469c0116fa47d711398a06 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Fri, 9 Sep 2016 08:38:44 +0200 Subject: [PATCH] Use Movepick SEE value in search This halves the calls to the costly pos.see_sign(), speed up is about 1-1.3% Non functional change. --- src/movepick.cpp | 5 +++++ src/movepick.h | 1 + src/search.cpp | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 78765bec..4971b304 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -243,6 +243,11 @@ void MovePicker::generate_next_stage() { } } +int MovePicker::see_sign() const +{ + return stage == GOOD_CAPTURES ? 1 + : stage == BAD_CAPTURES ? -1 : 0; +} /// next_move() is the most important method of the MovePicker class. It returns /// a new pseudo legal move every time it is called, until there are no more moves diff --git a/src/movepick.h b/src/movepick.h index 8028d487..e69255e6 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -104,6 +104,7 @@ public: MovePicker(const Position&, Move, Depth, Search::Stack*); Move next_move(); + int see_sign() const; private: template void score(); diff --git a/src/search.cpp b/src/search.cpp index 6182d9c5..1d930dd5 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -958,7 +958,8 @@ moves_loop: // When in check search starts from here } } else if ( depth < 3 * ONE_PLY - && pos.see_sign(move) < VALUE_ZERO) + && ( mp.see_sign() < 0 + || (!mp.see_sign() && pos.see_sign(move) < VALUE_ZERO))) continue; } -- 2.39.2