Improved time management
[owl.git] / engine.h
blobfdbb1ff86a53664a8badd47fd030c91571cd2352
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #ifndef NOLMR_MOVES
18 #define NOLMR_MOVES 3
19 #endif
21 /* killer heuristics */
22 struct killers_t {
23 int killer1;
24 int killer2;
25 int mate_killer;
28 struct counters_t {
29 uint64_t delta_prunings;
30 uint64_t evaluations;
31 uint64_t failed_high_first;
32 uint64_t failed_high_total;
33 uint64_t futility_prunings;
34 uint64_t null_move_prunings;
35 uint64_t misc;
36 uint64_t pawn_hash_evaluations;
37 uint64_t razorings;
38 uint64_t reductions;
39 uint64_t searched_nodes;
40 uint64_t transposition;
43 extern int history[2][7][4096]; /* cut off history */
44 extern int hash_moves[MAX_PLY]; /* moves from transposition
45 table (searched first) */
46 extern struct killers_t killers[MAX_PLY];
47 extern struct counters_t counters;
49 extern int pv[MAX_PLY][MAX_PLY];
50 extern int pv_length[MAX_PLY];
52 struct epd_info_t {
53 char *filename; /* filename of .epd file. we should free this pointer
54 after completing tests */
55 int think_time; /* time in seconds for each position */
56 int max_tests; /* max number of tests to do */
57 int first_test; /* start from */
60 struct engine_t {
61 int side; /* what engine's side */
62 int phase_factor;
64 int force_mode;
65 int post_mode;
66 int xboard_mode;
67 int play_computer; /* playing with a computer engine */
68 int san_notation; /* output thinking using SAN notation */
70 int max_depth; /* max search depth */
71 int max_time; /* max search time */
73 int chk_time; /* check for exit every chk_time nodes */
74 int time_div; /* assume all time for time_div moves */
75 int fixed_time; /* don't stop search before max_time elapsed */
76 uint32_t stop_time;
77 uint32_t max_stop_time;
78 int thinking; /* engine is thinking now */
79 pthread_t tid; /* thread id */
81 int pawn_hash_size; /* size of pawn hash table */
82 int main_hash_size; /* size of main hash table */
83 int pawn_hash_enabled; /* use pawn hashtable */
84 int main_hash_enabled; /* use main hashtable */
86 int resign; /* if TRUE engine resigs in bad positions */
87 int resign_value; /* resign if score is worse than this value */
88 int hopeless_moves; /* moves that made after score worse than
89 resign_value */
91 int delta_pruning;
92 int futility_pruning;
93 int iid;
94 int null_pruning;
95 int lmr;
96 int razoring;
98 pthread_mutex_t mutex;
101 extern struct engine_t e;
103 /* polyglot opening book functions */
104 void book_close(void);
105 void book_open(const char file_name[]);
106 int book_move(void);
108 void new_game(void);
109 void print_stats(int timediff);
110 void start_engine(void);
111 void perform_cleanup(void);
113 void loopcmd(void);
114 int check_time(int ply);
115 uint32_t get_time(void);
116 int get_engine_value(int *val);
117 void set_engine_value(int *src, int new_value);
119 /* these functions run in separate threads */
120 void *process_turn(void *args);
121 void *run_epd_test(void *args);