diff --git a/include/search/search_constants.h b/include/search/search_constants.h index 7a4e101..21861ae 100644 --- a/include/search/search_constants.h +++ b/include/search/search_constants.h @@ -69,7 +69,7 @@ using see_type = std::int32_t; inline constexpr std::size_t nodes_per_update = 512; -struct fixed_search_constants { +struct fixed_search_constants final { static constexpr bool tuning = false; static constexpr depth_type lmr_tbl_dim = 64; std::size_t thread_count_; @@ -151,6 +151,9 @@ struct fixed_search_constants { [[nodiscard]] constexpr depth_type probcut_search_depth(const depth_type& depth) const noexcept { return depth - 3; } [[nodiscard]] constexpr score_type probcut_beta(const score_type& beta) const noexcept { return beta + 315; } + [[nodiscard]] constexpr depth_type razor_depth() const noexcept { return 3; } + [[nodiscard]] constexpr score_type razor_margin(const depth_type& depth) const noexcept { return 896 * depth; } + [[maybe_unused]] fixed_search_constants& update_(const std::size_t& thread_count) noexcept { thread_count_ = thread_count; for (depth_type depth{1}; depth < lmr_tbl_dim; ++depth) { diff --git a/src/search/search_worker.cc b/src/search/search_worker.cc index 9f225d5..b9c706d 100644 --- a/src/search/search_worker.cc +++ b/src/search/search_worker.cc @@ -235,6 +235,14 @@ pv_search_result_t search_worker::pv_search( const bool improving = !is_check && ss.improving(); const chess::square_set threatened = bd.them_threat_mask(); + const bool try_razor = !is_pv && !is_check && !ss.has_excluded() && depth <= external.constants->razor_depth() && + value + external.constants->razor_margin(depth) <= alpha; + + if (try_razor) { + const score_type razor_score = q_search(ss, eval_node, bd, alpha, alpha + 1, 0); + if (razor_score <= alpha) { return make_result(razor_score, chess::move::null()); } + } + // step 7. static null move pruning const bool snm_prune = !is_pv && !ss.has_excluded() && !is_check && depth <= external.constants->snmp_depth() && value > beta + external.constants->snmp_margin(improving, threatened.any(), depth) && value > ss.loss_score();