1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#[derive(Clone)]
pub struct SearchParams {
    pub aspwin_delta: i16,
    pub aspwin_min_depth: i8,
    pub aspwin_max_width: i16,

    pub iir_min_depth: i8,
    pub iir_reduction_base: i8,
    pub iir_reduction_step: i8,
    pub iir_max_reduction: i8,

    pub razoring_min_depth: i8,
    pub razoring_max_depth: i8,
    pub razoring_depth_margin_base: i16,
    pub razoring_depth_margin_multiplier: i16,

    pub snmp_min_depth: i8,
    pub snmp_max_depth: i8,
    pub snmp_depth_margin_base: i16,
    pub snmp_depth_margin_multiplier: i16,

    pub nmp_min_depth: i8,
    pub nmp_min_game_phase: u8,
    pub nmp_margin: i16,
    pub nmp_depth_base: i8,
    pub nmp_depth_divider: i8,

    pub lmp_min_depth: i8,
    pub lmp_max_depth: i8,
    pub lmp_move_index_margin_base: usize,
    pub lmp_move_index_margin_multiplier: usize,
    pub lmp_max_score: i16,

    pub lmr_min_depth: i8,
    pub lmr_max_score: i16,
    pub lmr_min_move_index: usize,
    pub lmr_reduction_base: usize,
    pub lmr_reduction_step: usize,
    pub lmr_max_reduction: i8,
    pub lmr_pv_min_move_index: usize,
    pub lmr_pv_reduction_base: usize,
    pub lmr_pv_reduction_step: usize,
    pub lmr_pv_max_reduction: i8,

    pub q_score_pruning_treshold: i16,
    pub q_futility_pruning_margin: i16,
}

#[allow(non_upper_case_globals)]
impl SearchParams {
    pub const aspwin_delta: i16 = 25;
    pub const aspwin_min_depth: i8 = 5;
    pub const aspwin_max_width: i16 = 400;

    pub const iir_min_depth: i8 = 4;
    pub const iir_reduction_base: i8 = 1;
    pub const iir_reduction_step: i8 = 99;
    pub const iir_max_reduction: i8 = 3;

    pub const razoring_min_depth: i8 = 1;
    pub const razoring_max_depth: i8 = 5;
    pub const razoring_depth_margin_base: i16 = 260;
    pub const razoring_depth_margin_multiplier: i16 = 260;

    pub const snmp_min_depth: i8 = 1;
    pub const snmp_max_depth: i8 = 8;
    pub const snmp_depth_margin_base: i16 = 135;
    pub const snmp_depth_margin_multiplier: i16 = 55;

    pub const nmp_min_depth: i8 = 2;
    pub const nmp_min_game_phase: u8 = 3;
    pub const nmp_margin: i16 = 60;
    pub const nmp_depth_base: i8 = 2;
    pub const nmp_depth_divider: i8 = 5;

    pub const lmp_min_depth: i8 = 1;
    pub const lmp_max_depth: i8 = 3;
    pub const lmp_move_index_margin_base: usize = 2;
    pub const lmp_move_index_margin_multiplier: usize = 5;
    pub const lmp_max_score: i16 = -55;

    pub const lmr_min_depth: i8 = 2;
    pub const lmr_max_score: i16 = 90;
    pub const lmr_min_move_index: usize = 2;
    pub const lmr_reduction_base: usize = 1;
    pub const lmr_reduction_step: usize = 4;
    pub const lmr_max_reduction: i8 = 3;
    pub const lmr_pv_min_move_index: usize = 2;
    pub const lmr_pv_reduction_base: usize = 1;
    pub const lmr_pv_reduction_step: usize = 8;
    pub const lmr_pv_max_reduction: i8 = 2;

    pub const q_score_pruning_treshold: i16 = 0;
    pub const q_futility_pruning_margin: i16 = 100;
}

impl Default for SearchParams {
    /// Constructs a default instance of [SearchParams] with default elements.
    fn default() -> Self {
        Self {
            aspwin_delta: Self::aspwin_delta,
            aspwin_min_depth: Self::aspwin_min_depth,
            aspwin_max_width: Self::aspwin_max_width,

            iir_min_depth: Self::iir_min_depth,
            iir_reduction_base: Self::iir_reduction_base,
            iir_reduction_step: Self::iir_reduction_step,
            iir_max_reduction: Self::iir_max_reduction,

            razoring_min_depth: Self::razoring_min_depth,
            razoring_max_depth: Self::razoring_max_depth,
            razoring_depth_margin_base: Self::razoring_depth_margin_base,
            razoring_depth_margin_multiplier: Self::razoring_depth_margin_multiplier,

            snmp_min_depth: Self::snmp_min_depth,
            snmp_max_depth: Self::snmp_max_depth,
            snmp_depth_margin_base: Self::snmp_depth_margin_base,
            snmp_depth_margin_multiplier: Self::snmp_depth_margin_multiplier,

            nmp_min_depth: Self::nmp_min_depth,
            nmp_min_game_phase: Self::nmp_min_game_phase,
            nmp_margin: Self::nmp_margin,
            nmp_depth_base: Self::nmp_depth_base,
            nmp_depth_divider: Self::nmp_depth_divider,

            lmp_min_depth: Self::lmp_min_depth,
            lmp_max_depth: Self::lmp_max_depth,
            lmp_move_index_margin_base: Self::lmp_move_index_margin_base,
            lmp_move_index_margin_multiplier: Self::lmp_move_index_margin_multiplier,
            lmp_max_score: Self::lmp_max_score,

            lmr_min_depth: Self::lmr_min_depth,
            lmr_max_score: Self::lmr_max_score,
            lmr_min_move_index: Self::lmr_min_move_index,
            lmr_reduction_base: Self::lmr_reduction_base,
            lmr_reduction_step: Self::lmr_reduction_step,
            lmr_max_reduction: Self::lmr_max_reduction,
            lmr_pv_min_move_index: Self::lmr_pv_min_move_index,
            lmr_pv_reduction_base: Self::lmr_pv_reduction_base,
            lmr_pv_reduction_step: Self::lmr_pv_reduction_step,
            lmr_pv_max_reduction: Self::lmr_pv_max_reduction,

            q_score_pruning_treshold: Self::q_score_pruning_treshold,
            q_futility_pruning_margin: Self::q_futility_pruning_margin,
        }
    }
}