-
Notifications
You must be signed in to change notification settings - Fork 4
/
thordb.h
194 lines (127 loc) · 3.44 KB
/
thordb.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
File: thordb.h
Created: April 1, 1999
Modified: August 24, 2002
Author: Gunnar Andersson (gunnar@radagast.se)
Contents: An interface to the Thor database designed to
perform fast lookup operations.
*/
#ifndef THORDB_H
#define THORDB_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The fixed field lengths for entries in the tournament and player
lists respectively. These are fixed in the specifications for
the Thor database format. */
#define TOURNAMENT_NAME_LENGTH 26
#define PLAYER_NAME_LENGTH 20
/* Bit flags for the three categories of games */
#define GAME_HUMAN_HUMAN 1
#define GAME_HUMAN_PROGRAM 2
#define GAME_PROGRAM_PROGRAM 4
#define ALL_GAME_TYPES (GAME_HUMAN_HUMAN | \
GAME_HUMAN_PROGRAM | \
GAME_PROGRAM_PROGRAM)
/* Generate the frequency table? */
#define FULL_ANALYSIS 0
/* The ways the matching games can be sorted */
#define FIRST_SORT_ORDER 0
#define SORT_BY_YEAR 0
#define SORT_BY_YEAR_REVERSED 1
#define SORT_BY_BLACK_NAME 2
#define SORT_BY_WHITE_NAME 3
#define SORT_BY_TOURNAMENT 4
#define SORT_BY_BLACK_SCORE 5
#define SORT_BY_WHITE_SCORE 6
#define LAST_SORT_ORDER 6
typedef struct {
const char *black_name;
const char *white_name;
const char *tournament;
int year;
int black_actual_score;
int black_corrected_score;
} GameInfoType;
typedef struct {
int year;
int count;
} DatabaseInfoType;
typedef enum { EitherSelectedFilter, BothSelectedFilter,
BlackSelectedFilter, WhiteSelectedFilter } PlayerFilterType;
int
read_player_database( const char *file_name );
const char *
get_player_name( int index );
int get_player_count( void );
int
read_tournament_database( const char *file_name );
const char *
get_tournament_name( int index );
int get_tournament_count( void );
int
read_game_database( const char *file_name );
int
game_database_already_loaded( const char *file_name );
int
get_database_count( void );
void
get_database_info( DatabaseInfoType *info );
int
choose_thor_opening_move( int *in_board, int side_to_move, int echo );
void
set_player_filter( int *selected );
void
set_player_filter_type( PlayerFilterType player_filter );
void
set_tournament_filter( int *selected );
void
set_year_filter( int first_year, int last_year );
void
specify_game_categories( int categories );
void
database_search( int *in_board, int side_to_move );
void
init_thor_database( void );
#if FULL_ANALYSIS
void
frequency_analysis( int game_count );
#endif
int
get_thor_game_size( void );
void
specify_thor_sort_order( int count, int *sort_order );
void
print_thor_matches( FILE *stream, int max_games );
int
get_total_game_count( void );
int
get_match_count( void );
int
get_black_win_count( void );
int
get_draw_count( void );
int
get_white_win_count( void );
int
get_black_median_score( void );
double
get_black_average_score( void );
int
get_move_frequency( int move );
double
get_move_win_rate( int move );
GameInfoType
get_thor_game( int index );
void
get_thor_game_moves( int index, int *move_count, int *moves );
int
get_thor_game_move_count( int index );
int
get_thor_game_move( int index,
int move_number );
#ifdef __cplusplus
}
#endif
#endif /* THORDB_H */