Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,10 @@ Value Worker::search(
}

if (!PV_NODE && !is_in_check && !pos.is_kp_endgame() && depth >= tuned::nmp_depth && !excluded
&& tt_adjusted_eval >= beta + 30 && !is_being_mated_score(beta) && !m_in_nmp_verification) {
int R =
tuned::nmp_base_r + depth / 4 + std::min(3, (tt_adjusted_eval - beta) / 400) + improving;
&& tt_adjusted_eval >= beta + tuned::nmp_beta_margin && !is_being_mated_score(beta)
&& !m_in_nmp_verification) {
int R = tuned::nmp_base_r + depth / 4
+ std::min(3, (tt_adjusted_eval - beta) / tuned::nmp_beta_diff) + improving;
Position pos_after = pos.null_move();

repetition_info.push(pos_after.get_hash_key(), true);
Expand Down Expand Up @@ -629,16 +630,16 @@ Value Worker::search(
extension = 1;

// Double Extension
int double_margin =
tuned::sing_double_margin - (move_history / tuned::sing_hist_div * quiet);
Value double_margin =
tuned::dext_margin - (move_history / tuned::dext_hist_div * quiet);
if (!PV_NODE && singular_value <= singular_beta - double_margin) {
extension = 2;
}

// Triple Extension
int triple_margin = tuned::sing_triple_margin - (move_history / 512 * quiet);
if (!PV_NODE && quiet
&& singular_value <= singular_beta - tuned::sing_triple_margin) {
Value triple_margin =
tuned::triext_margin - (move_history / tuned::triext_hist_div * quiet);
if (!PV_NODE && quiet && singular_value <= singular_beta - triple_margin) {
extension = 3;
}
}
Expand Down
22 changes: 16 additions & 6 deletions src/tm.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "tm.hpp"
#include "tuned.hpp"
#include "uci.hpp"
#include "util/types.hpp"
#include <iostream>
Expand All @@ -15,9 +16,9 @@ time::TimePoint compute_hard_limit(time::TimePoint search_start,
if (settings.w_time >= 0) {
const auto compute_buffer_time = [&]() -> i64 {
if (stm == Color::White) {
return settings.w_time / 4;
return settings.w_time * tuned::time_hard_limit / 1024;
} else {
return settings.b_time / 4;
return settings.b_time * tuned::time_hard_limit / 1024;
}
};
hard_limit = min(hard_limit, search_start + Milliseconds(compute_buffer_time()));
Expand Down Expand Up @@ -46,9 +47,11 @@ time::TimePoint compute_soft_limit(time::TimePoint search_start,
// Base time calculation
const auto compute_buffer_time = [&]() -> f64 {
if (stm == Color::White) {
return static_cast<f64>(settings.w_time / 20 + settings.w_inc / 2);
return static_cast<f64>(settings.w_time * tuned::time_soft_limit / 1024
+ settings.w_inc * tuned::time_soft_increment / 1024);
} else {
return static_cast<f64>(settings.b_time / 20 + settings.b_inc / 2);
return static_cast<f64>(settings.b_time * tuned::time_soft_limit / 1024
+ settings.b_inc * tuned::time_soft_increment / 1024);
}
};

Expand All @@ -57,13 +60,20 @@ time::TimePoint compute_soft_limit(time::TimePoint search_start,
if constexpr (!ADJUST_FOR_NODES_TM) {
return 1.0;
}
return std::max<f64>(0.5, 2.0 - nodes_tm_fraction * (100.0 / 54.038));
return std::max<f64>(tuned::nodetm_min_factor / 1024.0,
tuned::nodetm_avg_factor / 1024.0
- nodes_tm_fraction * (tuned::nodetm_frac_factor / 1024.0));
};

// Adjustment based on difference between depth 1 search score and current score
// This essentially estimates the complexity of a position
const auto compute_complexitytm_factor = [&]() -> f64 {
return std::max<f64>(0.77 + std::clamp<f64>(complexity, 0.0, 200.0) / 386.0, 1.0);
return std::max<f64>(
tuned::d1plexity_base / 1024.0
+ std::clamp<f64>(complexity, 0.0,
static_cast<f64>(tuned::d1plexity_max_complexity))
/ static_cast<f64>(tuned::d1plexity_divisor),
1.0);
};

soft_limit =
Expand Down
20 changes: 17 additions & 3 deletions src/tuned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace Clockwork::tuned {
NO_TUNE(nmp_depth, 3, 1, 10, .5, 0.002) \
NO_TUNE(nmp_base_r, 3, 1, 10, .5, 0.002) \
NO_TUNE(nmp_verif_min_depth, 14, 1, 40, .5, 0.002) \
TUNE(nmp_beta_margin, 30, 10, 60, 3, 0.002) \
TUNE(nmp_beta_diff, 400, 200, 800, 38, 0.002) \
\
/* ProbCut Values */ \
TUNE(probcut_margin, 300, 100, 500, 10, 0.002) \
Expand Down Expand Up @@ -60,9 +62,10 @@ namespace Clockwork::tuned {
NO_TUNE(sing_min_depth, 6, 1, 20, 0.5, 0.002) \
NO_TUNE(sing_depth_margin, 3, 1, 20, 0.5, 0.002) \
TUNE(sing_beta_margin, 5, 2, 10, 1, 0.002) \
TUNE(sing_double_margin, 40, 20, 80, 3, 0.002) \
TUNE(sing_hist_div, 512, 256, 1024, 39, 0.002) \
TUNE(sing_triple_margin, 120, 60, 240, 9, 0.002) \
TUNE(dext_margin, 40, 20, 80, 3, 0.002) \
TUNE(dext_hist_div, 512, 256, 1024, 39, 0.002) \
TUNE(triext_margin, 120, 60, 240, 9, 0.002) \
TUNE(triext_hist_div, 512, 256, 1024, 39, 0.002) \
\
/* LMR */ \
TUNE(lmr_quiet_base, 788, 394, 1576, 59, 0.002) \
Expand All @@ -85,6 +88,17 @@ namespace Clockwork::tuned {
TUNE(lmr_fut_red, 1024, 512, 2048, 77, 0.002) \
TUNE(lmr_max_red, 3072, 1536, 6144, 231, 0.002) \
\
/* TIME MANAGEMENT */ \
TUNE(time_hard_limit, 256, 128, 512, 19, 0.002) \
TUNE(time_soft_limit, 51, 25, 100, 3, 0.002) \
TUNE(time_soft_increment, 512, 256, 1024, 38, 0.002) \
TUNE(nodetm_min_factor, 512, 256, 1024, 38, 0.002) \
TUNE(nodetm_avg_factor, 2048, 1024, 4096, 153, 0.002) \
TUNE(nodetm_frac_factor, 1895, 948, 3792, 142, 0.002) \
TUNE(d1plexity_base, 788, 394, 1576, 59, 0.002) \
TUNE(d1plexity_max_complexity, 200, 100, 400, 15, 0.002) \
TUNE(d1plexity_divisor, 386, 193, 772, 29, 0.002) \
\
/* End of Tunables */

#define DEFINE_VARIABLE(NAME, DEFAULT, ...) inline i32 NAME = DEFAULT;
Expand Down
Loading