-
Notifications
You must be signed in to change notification settings - Fork 4
/
search.h
168 lines (105 loc) · 3.14 KB
/
search.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
File: search.h
Created: July 1, 1997
Modified: August 1, 2002
Author: Gunnar Andersson (gunnar@radagast.se)
Contents: The interface to common search routines and variables.
*/
#ifndef SEARCH_H
#define SEARCH_H
#include "constant.h"
#include "counter.h"
#include "globals.h"
#ifdef __cplusplus
extern "C" {
#endif
#define USE_RANDOMIZATION TRUE
#define USE_HASH_TABLE TRUE
#define CHECK_HASH_CODES FALSE
#define MOVE_ORDER_SIZE 60
#define INFINITE_EVAL 12345678
typedef enum { MIDGAME_EVAL, EXACT_EVAL, WLD_EVAL, SELECTIVE_EVAL,
FORCED_EVAL, PASS_EVAL, UNDEFINED_EVAL, INTERRUPTED_EVAL,
UNINITIALIZED_EVAL } EvalType;
typedef enum { WON_POSITION, DRAWN_POSITION,
LOST_POSITION, UNSOLVED_POSITION } EvalResult;
/* All information available about a move decision. */
typedef struct {
EvalType type;
EvalResult res;
int score; /* For BOOK, MIDGAME and EXACT */
double confidence; /* For SELECTIVE */
int search_depth; /* For MIDGAME */
int is_book;
} EvaluationType;
/* The time spent searching during the game. */
extern double total_time;
/* The value of the root position from the last midgame or
endgame search. Can contain strange values if an event
occurred. */
extern int root_eval;
/* Event flag which forces the search to abort immediately when set. */
extern int force_return;
/* The number of positions evaluated during the current search. */
extern CounterType evaluations;
/* The number of positions evaluated during the entire game. */
extern CounterType total_evaluations;
/* Holds the number of nodes searched during the current search. */
extern CounterType nodes;
/* Holds the total number of nodes searched during the entire game. */
extern CounterType total_nodes;
/* The last available evaluations for all possible moves at all
possible game stages. */
extern Board evals[61];
/* Move lists */
extern int sorted_move_order[64][64]; /* 61*60 used */
/* The principal variation including passes */
extern int full_pv_depth;
extern int full_pv[120];
/* JCW's move order */
extern int position_list[100];
void
inherit_move_lists( int stage );
void
reorder_move_list( int stage );
void
setup_search( void );
int
disc_count( int side_to_move );
void
sort_moves( int list_size );
int
select_move( int first, int list_size );
int
float_move( int move, int list_size );
void
store_pv( int *pv_buffer, int *depth_buffer );
void
restore_pv( int *pv_buffer, int depth_buffer );
void
clear_pv( void );
void
set_ponder_move( int move );
void
clear_ponder_move( void );
int
get_ponder_move( void );
EvaluationType
create_eval_info( EvalType in_type, EvalResult in_res, int in_score,
double in_conf, int in_depth, int in_book );
double
produce_compact_eval( EvaluationType eval_info );
void
complete_pv( int side_to_move );
void
hash_expand_pv( int side_to_move, int mode, int flags, int max_selectivity );
void
set_current_eval( EvaluationType eval );
EvaluationType
get_current_eval( void );
void
negate_current_eval( int negate );
#ifdef __cplusplus
}
#endif
#endif /* SEARCH_H */