-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCheckerBoard.h
245 lines (217 loc) · 7.41 KB
/
CheckerBoard.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
// CheckerBoard.h contains definitions relevant
// for the file CheckerBoard.c. common constants
// relevant for the entire program are defined in
// CBconsts.h
#pragma once
#include <vector>
#include "CB_movegen.h"
// version
#define VERSION "1.77a"
#define PLACE "July 16, 2022"
#define OP_CROSSBOARD 1 // different opening decks
#define OP_MAILPLAY 2
#define OP_BARRED 4
#define OP_CTD 8 /* "Computer tough deck", selected by Mac Banks for the 2002 Las Vegas computer checkers tournament. */
#define NUMBUTTONS 23 //number of buttons in toolbar
#define MAXUSERBOOK 10000
#define SLEEPTIME 20 // number of ms to sleep
#define AUTOSLEEPTIME 20 // run autothread at 50 Hz
#define OF_SAVEGAME 0
#define OF_LOADGAME 1
#define OF_SAVEASHTML 2
#define OF_USERBOOK 3
#define OF_BOOKFILE 4 /* Opening book filenme. */
#define MAXPIECESET 16
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
// window functions
BOOL InitApplication(HINSTANCE);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK CB_edit_func(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
// thread functions
DWORD AutoThreadFunc(LPVOID param);
DWORD SearchThreadFunc(LPVOID param);
// my functions in alphabetical list
void abortengine();
int addmovetouserbook(Board8x8 board, CBmove *move);
void add_piecesets_to_menu(HMENU hmenu);
void addmovetogame(CBmove &move, char *pdn);
int islegal_check(Board8x8 board, int color, Squarelist &squares, CBmove *move, int gametype);
int num_matching_moves(Board8x8 board, int color, Squarelist &squares, CBmove &move, int gametype);
bool move_to_pdn_english(int nmoves, CBmove movelist[MAXMOVES], CBmove *move, char *pdn, int gametype);
bool move_to_pdn_english(Board8x8 board, int color, CBmove *move, char *pdn, int gametype);
int changeCBstate(int newstate);
HWND CreateAToolBar(HWND hwndParent);
int createcheckerboard(HWND hwnd);
bool doload(PDNgame *PDNgame, const char *gamestring, int *color, Board8x8 board, std::string &errormsg);
int domove(const CBmove &m, Board8x8 board);
int update_match_stats(int result, int movecount, int gamenumber, emstats_t *stats);
void emlog_filename(char *filename);
void empdn_filename(char *filename);
void emprogress_filename(char *filename);
void emstats_filename(char *filename);
int enginecommand(const char *command, char reply[ENGINECOMMAND_REPLY_SIZE]);
int enginename(char str[MAXNAME]);
void get_game_clocks(double *black_clock, double *white_clock);
void get_pdnsearch_stats(std::vector<gamepreview> &previews, RESULT_COUNTS &res);
int get_startcolor(int gametype);
char *pdn_result_to_string(PDN_RESULT result, int gametype);
PDN_RESULT string_to_pdn_result(char *resultstr, int gametype);
int getfilename(char filename[255], int what);
int getanimationbusy(void);
int getenginebusy(void);
int getenginestarting(void);
int getmovelist(int color, CBmove movelist[MAXMOVES], Board8x8 board, int *isjump);
int gametype(void);
int handlegamereplace(int replaceindex, char *databasename);
int handlesetupcc(int *color);
int handletimer(void);
int handle_lbuttondown(int x, int y);
int handle_rbuttondown(int x, int y);
void InitCheckerBoard(Board8x8 board);
void initengines(void);
int is_mirror_gametype(int gametype);
int is_row_reversed_gametype(int gametype);
void loadengines(char *pri_fname, char *sec_fname);
HWND InitHeader(HWND hwnd);
void InitStatus(HWND hwnd);
int loadgamefromPDNstring(int gameindex, char *dbstring);
int loadnextgame(void);
int loadpreviousgame(void);
char *loadPDNdbstring(char *dbname);
int makeanalysisfile(char *filename);
bool match_is_resumable(void);
void move4tonotation(const CBmove &move, char str[80]);
void newgame(void);
int num_ballots(void);
void PDNgametoPDNstring(PDNgame &game, std::string &pdnstring, char *lineterm);
bool pdntogame(PDNgame &game, Board8x8 startposition, int startcolor, std::string &errormsg);
int read_match_stats(void);
void reset_match_stats(void);
void setcurrentengine(int engine);
void togglecurrentengine(void);
int SetMenuLanguage(int language);
int selectgame(int how);
int setanimationbusy(int value);
int setenginebusy(int value);
int setenginestarting(int value);
int showfile(char *filename);
int start3move(int opening_index);
int undomove(CBmove &move, Board8x8 board);
int get_movelist_from_engine(Board8x8 board, int color, CBmove movelist[], int *nmoves, int *iscapture);
extern char CBdirectory[MAX_PATH]; // holds the directory from where CB is started:
extern char CBdocuments[MAX_PATH];
#define random(x) (rand() % x);
#define TOGGLEBOOK 1000
#define TOGGLEMODE 1001
#define TOGGLEENGINE 1002
#define LOADENGINES 1003
#define GAMENEW 101
#define GAME3MOVE 102
#define GAMELOAD 103
#define GAMESAVE 104
#define GAMEINFO 105
#define GAMEANALYZE 106
#define GAMECOPY 107
#define GAMEPASTE 108
#define GAMEEXIT 109
#define GAMEDATABASE 110
#define START3MOVE 111
#define DOSAVE 112
#define GAMEREPLACE 113
#define GAMEFIND 114
#define GAMEFINDCR 123
#define GAMEFINDTHEME 115
#define GAMESAVEASHTML 116
#define DOSAVEHTML 117
#define DIAGRAM 118
#define GAMEFINDPLAYER 119
#define SEARCHMASK 119
#define GAME_FENTOCLIPBOARD 120
#define GAME_FENFROMCLIPBOARD 121
#define SELECTUSERBOOK 122
#define RE_SEARCH 124
#define LOADNEXT 125
#define LOADPREVIOUS 126
#define GAMEANALYZEPDN 127
#define SAMPLEDIAGRAM 128
#define MOVESPLAY 201
#define MOVESBACK 202
#define MOVESFORWARD 203
#define MOVESBACKALL 204
#define MOVESFORWARDALL 205
#define MOVESCOMMENT 207
#define INTERRUPTENGINE 206
#define ABORTENGINE 208
// options menu
#define LEVELEXACT 340
#define LEVELINSTANT 341
#define LEVEL01S 357
#define LEVEL02S 358
#define LEVEL05S 359
#define LEVEL1S 342
#define LEVEL2S 343
#define LEVEL5S 344
#define LEVEL10S 356
#define LEVEL15S 345
#define LEVEL30S 346
#define LEVEL1M 347
#define LEVEL2M 348
#define LEVEL5M 349
#define LEVEL15M 350
#define LEVEL30M 351
#define LEVELINFINITE 352
#define LEVELINCREMENT 353
#define LEVELADDTIME 354
#define LEVELSUBTRACTTIME 355
#define PIECESET 380
#define OPTIONSHIGHLIGHT 322
#define OPTIONSSOUND 323
#define OPTIONSPRIORITY 324
#define OPTIONS3MOVE 40001
#define OPTIONSDIRECTORIES 40002
#define OPTIONSUSERBOOK 325
#define OPTIONSLANGUAGEENGLISH 370
#define OPTIONSLANGUAGEESPANOL 371
#define OPTIONSLANGUAGEITALIANO 372
#define OPTIONSLANGUAGEDEUTSCH 373
#define OPTIONSLANGUAGEFRANCAIS 374
#define DISPLAYINVERT 308
#define DISPLAYNUMBERS 309
#define DISPLAYMIRROR 3091
#define CM_NORMAL 310
#define CM_ANALYSIS 311
#define GOTONORMAL 312
#define CM_AUTOPLAY 313
#define CM_2PLAYER 315
#define ENGINEVSENGINE 316
#define COLORBOARDNUMBERS 330
#define COLORHIGHLIGHT 331
#define BOOKMODE_VIEW 360
#define BOOKMODE_ADD 361
#define BOOKMODE_DELETE 362
// help menu
#define HELPHELP 401
#define HELPABOUT 402
#define HELPCHECKERSINANUTSHELL 403
#define HELPHOMEPAGE 405
#define PROBLEMOFTHEDAY 406
#define ONLINEUPGRADE 407
#define SETUPMODE 501
#define SETUPCLEAR 502
#define SETUPBLACK 503
#define SETUPWHITE 504
#define SETUPCC 505
#define ENGINESELECT 600
#define ENGINEABOUT 602
#define ENGINEHELP 603
#define ENGINEOPTIONS 604
#define CM_ENGINEMATCH 800
#define CM_ADDCOMMENT 802
#define ENGINEEVAL 803
#define CM_ENGINECOMMAND 804
#define CM_RUNTESTSET 805
#define CM_HANDICAP 806
#define CM_BUILDEGDB 900
#define IDTB_BMP 300
#define ID_TOOLBAR 200