-
Notifications
You must be signed in to change notification settings - Fork 8
/
chrono.h
81 lines (67 loc) · 2.32 KB
/
chrono.h
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
/*
Fire is a freeware UCI chess playing engine authored by Norman Schmidt.
Fire utilizes many state-of-the-art chess programming ideas and techniques
which have been documented in detail at https://www.chessprogramming.org/
and demonstrated via the very strong open-source chess engine Stockfish...
https://github.com/official-stockfish/Stockfish.
Fire is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or any later version.
You should have received a copy of the GNU General Public License with
this program: copying.txt. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "fire.h"
typedef std::chrono::milliseconds::rep time_point;
typedef movelist<max_moves> max_moves_list;
inline time_point now()
{
return std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::steady_clock::now().time_since_epoch()).count();
}
struct search_limit
{
search_limit()
{
nodes = time[white] = time[black] = inc[white] = inc[black] =
moves_to_go = depth = move_time = mate = infinite = ponder = 0;
}
[[nodiscard]] bool use_time_calculating() const
{
return !(mate | move_time | depth | nodes | infinite);
}
time_point start_time = 0;
int time[num_sides]{}, inc[num_sides]{}, moves_to_go, depth, move_time, mate, infinite, ponder;
uint64_t nodes;
max_moves_list search_moves;
};
class timecontrol
{
public:
void init(search_limit& limit, side me, int ply);
[[nodiscard]] int64_t optimum() const {return optimal_time_;}
[[nodiscard]] int64_t maximum() const {return maximum_time_;}
[[nodiscard]] int64_t elapsed() const;
[[nodiscard]] double calc_move_importance(int ply) const;
void adjustment_after_ponder_hit();
private:
time_point start_time_ = 0;
int64_t optimal_time_ = 0;
int64_t maximum_time_ = 0;
// calc_move_importance parameters
double x_scale_ = 7.64;
double x_shift_ = 58.4;
double skew_ = 0.183;
double factor_base_ = 1.225;
double ply_factor_ = 0.00025;
int ply_min_ = 10;
int ply_max_ = 70;
int base_moves_ = 50;
double move_importance_factor_ = 0.89;
int moves_horizon_ = 50;
double max_ratio_ = 7.09;
double steal_ratio_ = 0.35;
int64_t minimum_time_ = 1;
int move_overhead_ = 10;
};
extern timecontrol time_control;