My Project
ui.h
Go to the documentation of this file.
1
12#ifndef EDAX_UI_H
13#define EDAX_UI_H
14
15#include "board.h"
16#include "book.h"
17#include "event.h"
18#include "search.h"
19#include "move.h"
20#include "play.h"
21
22#ifdef DLL_BUILD
23#define DLL_API __declspec(dllexport)
24#else
25#define DLL_API
26#endif
27
31typedef struct UI {
34 struct GGSClient *ggs;
36 int type;
37 int mode;
38 Event event[1];
40 void (*init)(struct UI*);
41 void (*loop)(struct UI*);
42 void (*free)(struct UI*);
44
48typedef struct BenchResult {
49 unsigned long long T;
50 unsigned long long n_nodes;
52 Lock lock;
54
55bool ui_switch(UI*, const char*);
56
57void ui_event_init(UI*);
58bool ui_event_peek(UI*, char**, char**);
59void ui_event_wait(UI*, char**, char**);
60bool ui_event_exist(UI*);
61void ui_event_free(UI*);
62
63void ui_init_edax(UI*);
64void ui_loop_edax(UI*);
65void ui_free_edax(UI*);
66
67void ui_init_gtp(UI*);
68void ui_loop_gtp(UI*);
69void ui_free_gtp(UI*);
70
71void ui_init_nboard(UI*);
72void ui_loop_nboard(UI*);
73void ui_free_nboard(UI*);
74
75void ui_init_xboard(UI*);
76void ui_loop_xboard(UI*);
77void ui_free_xboard(UI*);
78
79void ui_init_ggs(UI*);
80void ui_loop_ggs(UI*);
81void ui_free_ggs(UI*);
82
86
88
89// add for libedax by lavox. 2018/1/19
90// api functions
91DLL_API void libedax_initialize(int, char**);
92DLL_API void libedax_terminate(void);
93DLL_API void edax_init(void);
94DLL_API void edax_new(void);
95DLL_API void edax_load(const char*);
96DLL_API void edax_save(const char*);
97DLL_API void edax_undo(void);
98DLL_API void edax_redo(void);
99DLL_API void edax_mode(const int);
100DLL_API void edax_setboard(const char*);
101DLL_API void edax_setboard_from_obj(const Board*, const int);
102DLL_API void edax_vmirror(void);
103DLL_API void edax_hmirror(void);
104DLL_API void edax_rotate(const int);
105DLL_API void edax_symetry(const int);
106DLL_API void edax_play(char*);
107DLL_API void edax_force(char*);
108DLL_API void edax_bench(BenchResult*, int);
110DLL_API void edax_go(void);
111DLL_API void edax_hint(const int, HintList*);
118DLL_API void edax_stop(void);
119DLL_API void edax_version(void);
120DLL_API int edax_move(const char*);
121DLL_API void edax_options_dump(void);
122DLL_API const char* edax_opening(void);
123DLL_API const char* edax_ouverture(void);
124DLL_API void edax_book_store(void);
125DLL_API void edax_book_on(void);
126DLL_API void edax_book_off(void);
127DLL_API void edax_book_randomness(const int);
128DLL_API void edax_book_depth(const int);
129DLL_API void edax_book_new(const int, const int);
130DLL_API void edax_book_load(const char*);
131DLL_API void edax_book_save(const char*);
132DLL_API void edax_book_import(const char*);
133DLL_API void edax_book_export(const char*);
134DLL_API void edax_book_merge(const char*);
135DLL_API void edax_book_fix(void);
136DLL_API void edax_book_negamax(void);
137DLL_API void edax_book_correct(void);
138DLL_API void edax_book_prune(void);
139DLL_API void edax_book_subtree(void);
144DLL_API void edax_book_count_board_bestpath(Board*, Position*, const int, const int, const int);
146DLL_API void edax_book_verbose(const int);
147DLL_API void edax_book_add(const char*);
148DLL_API void edax_book_check(const char*);
149DLL_API void edax_book_extract(const char*);
150DLL_API void edax_book_deviate(int, int);
151DLL_API void edax_book_enhance(int, int);
152DLL_API void edax_book_fill(int);
153DLL_API void edax_book_play(void);
154DLL_API void edax_book_deepen(void);
159
160DLL_API void edax_base_problem(const char*, const int, const char*);
161DLL_API void edax_base_tofen(const char*, const int, const char*);
162DLL_API void edax_base_correct(const char*, const int);
163DLL_API void edax_base_complete(const char*);
164DLL_API void edax_base_convert(const char*, const char*);
165DLL_API void edax_base_unique(const char*, const char*);
166DLL_API void edax_set_option(const char*, const char*);
167
168DLL_API char* edax_get_moves(char*);
169DLL_API int edax_is_game_over(void);
170DLL_API int edax_can_move(void);
174DLL_API int edax_get_disc(const int);
175DLL_API int edax_get_mobility_count(const int);
176DLL_API void edax_play_print(void);
180DLL_API int edax_board_get_square_color(const Board*, const int);
181
182// internal functions
184void ui_init_libedax(UI*);
185void ui_free_libedax(UI*);
186void auto_go(void);
187
190
191#endif
Edax play control - header file.
Definition: ui.h:48
unsigned long long T
Definition: ui.h:49
Lock lock
Definition: ui.h:52
int positions
Definition: ui.h:51
unsigned long long n_nodes
Definition: ui.h:50
Definition: board.h:26
The opening book.
Definition: book.h:25
Definition: event.h:18
Definition: ggs.c:146
Definition: search.h:81
Definition: search.h:62
Definition: move.h:29
Definition: move.h:20
Definition: play.h:25
A position stored in the book.
Definition: book.h:77
Definition: search.h:41
Definition: ui.h:31
struct GGSClient * ggs
Definition: ui.h:34
int type
Definition: ui.h:36
Play play[2]
Definition: ui.h:32
Book book[1]
Definition: ui.h:33
void(* init)(struct UI *)
Definition: ui.h:40
bool is_same_play
Definition: ui.h:35
void(* loop)(struct UI *)
Definition: ui.h:41
int mode
Definition: ui.h:37
void(* free)(struct UI *)
Definition: ui.h:42
void ui_init_cassio(UI *)
bool ui_event_exist(UI *)
ui_event_exist
Definition: ui.c:189
DLL_API void edax_book_prune(void)
book prune command.
Definition: libedax.c:910
void ui_init_gtp(UI *)
initialize edax protocol
Definition: gtp.c:93
DLL_API void edax_setboard_from_obj(const Board *, const int)
setboard command with board object.
Definition: libedax.c:277
DLL_API void edax_undo(void)
undo command.
Definition: libedax.c:226
void ui_free_xboard(UI *)
free resources used by xboard protocol.
Definition: xboard.c:97
DLL_API void edax_set_option(const char *, const char *)
set (option) command.
Definition: libedax.c:1382
DLL_API void edax_base_tofen(const char *, const int, const char *)
base tofen command.
Definition: libedax.c:1275
void ui_init_libedax(UI *)
initialize libedax api.
Definition: libedax.c:114
#define DLL_API
Definition: ui.h:25
DLL_API void edax_force(char *)
force command.
Definition: libedax.c:361
void ui_free_ggs(UI *)
ui_free_ggs
Definition: ggs.c:1599
DLL_API int edax_can_move(void)
check if the current player can move.
Definition: libedax.c:1430
DLL_API char * edax_get_moves(char *)
get moves of the current game.
Definition: libedax.c:1403
DLL_API void edax_book_randomness(const int)
book randomness command.
Definition: libedax.c:729
DLL_API void edax_vmirror(void)
vmirror command.
Definition: libedax.c:287
DLL_API void edax_base_complete(const char *)
base complete command.
Definition: libedax.c:1321
DLL_API void edax_base_convert(const char *, const char *)
base convert command.
Definition: libedax.c:1341
DLL_API int edax_get_mobility_count(const int)
get current number of legal moves.
Definition: libedax.c:1490
DLL_API int edax_board_is_pass(const Board *)
Check if current player should pass.
Definition: libedax.c:1533
DLL_API void edax_book_load(const char *)
book load command.
Definition: libedax.c:775
DLL_API void edax_book_show(Position *)
book show command.
Definition: libedax.c:962
void ui_loop_ggs(UI *)
ui_loop_ggs
Definition: ggs.c:1418
DLL_API void edax_mode(const int)
mode command.
Definition: libedax.c:249
DLL_API void edax_book_stats_clean(void)
book stats clean command.
Definition: libedax.c:947
DLL_API void edax_book_correct(void)
book correct command.
Definition: libedax.c:892
DLL_API void edax_options_dump(void)
dump options.
Definition: libedax.c:631
DLL_API int edax_get_bookmove_with_position_by_moves(const char *, MoveList *, Position *)
get book moves.
Definition: libedax.c:542
void ui_book_init(UI *)
DLL_API void edax_hint_next_no_multipv_depth(Hint *)
hint command. Gets hint one by one. If there are no more hints, hint will be NOMOVE....
Definition: libedax.c:588
DLL_API int edax_get_bookmove_with_position(MoveList *, Position *)
get book moves.
Definition: libedax.c:532
DLL_API void edax_get_board(Board *)
get current board.
Definition: libedax.c:1456
DLL_API void edax_book_add(const char *)
book add command.
Definition: libedax.c:1064
DLL_API void edax_book_deviate(int, int)
book deviate command.
Definition: libedax.c:1131
DLL_API void edax_book_play(void)
book play command.
Definition: libedax.c:1183
DLL_API void edax_get_last_move(Move *)
get last move.
Definition: libedax.c:1440
DLL_API void edax_book_deepen(void)
book deepen command. caution: Currently, this function does not work correctly.
Definition: libedax.c:1198
void ui_init_xboard(UI *)
initialize xboard protocol.
Definition: xboard.c:72
DLL_API void edax_play(char *)
play command.
Definition: libedax.c:347
DLL_API void edax_book_depth(const int)
book depth command.
Definition: libedax.c:743
DLL_API void edax_play_print(void)
print play.
Definition: libedax.c:1502
void ui_loop_gtp(UI *)
Loop event.
Definition: gtp.c:127
DLL_API int edax_move(const char *)
user move command.
Definition: libedax.c:618
DLL_API void edax_book_fix(void)
book fix command.
Definition: libedax.c:860
void book_cmd_pre_process(UI *)
pre-process of book command.
Definition: libedax.c:667
DLL_API void edax_book_check(const char *)
book check command.
Definition: libedax.c:1083
void ui_loop_edax(UI *)
Loop event.
Definition: edax.c:284
DLL_API void edax_book_negamax(void)
book negamax command.
Definition: libedax.c:877
DLL_API void edax_book_import(const char *)
book import command.
Definition: libedax.c:806
DLL_API void edax_hmirror(void)
hmirror command.
Definition: libedax.c:297
DLL_API void edax_get_bookmove(MoveList *)
get book moves.
Definition: libedax.c:523
DLL_API void edax_book_fill(int)
book fill command.
Definition: libedax.c:1168
void auto_go(void)
auto go with regard to mode.
Definition: libedax.c:145
DLL_API void edax_book_add_board_post_process(void)
book add board postprocess.
Definition: libedax.c:1237
void ui_free_edax(UI *)
free resources used by edax protocol.
Definition: edax.c:157
DLL_API void edax_load(const char *)
load command.
Definition: libedax.c:205
DLL_API void edax_new(void)
new command.
Definition: libedax.c:194
DLL_API void edax_book_verbose(const int)
book verbose command.
Definition: libedax.c:1042
void ui_free_gtp(UI *)
free resources used by edax protocol
Definition: gtp.c:115
DLL_API void libedax_initialize(int, char **)
edax init function for library use.
Definition: libedax.c:41
DLL_API void edax_book_stop_count_bestpath(void)
stop counting the number of best paths in book.
Definition: libedax.c:1026
DLL_API void edax_hint(const int, HintList *)
hint command.
Definition: libedax.c:512
DLL_API int edax_is_game_over(void)
check if the current game is over.
Definition: libedax.c:1421
void ui_loop_nboard(UI *)
Loop event.
Definition: nboard.c:113
void ui_loop_cassio(UI *)
DLL_API int edax_get_current_player(void)
get current player.
Definition: libedax.c:1468
void ui_free_cassio(UI *)
DLL_API void edax_book_enhance(int, int)
book enhance command.
Definition: libedax.c:1150
void ui_event_wait(UI *, char **, char **)
Wait input.
Definition: ui.c:147
DLL_API void edax_base_unique(const char *, const char *)
base unique command.
Definition: libedax.c:1357
DLL_API void edax_hint_prepare(MoveList *)
hint command. Call edax_hint_next after calling this function.
Definition: libedax.c:559
DLL_API void edax_book_merge(const char *)
book merge command.
Definition: libedax.c:841
bool ui_event_peek(UI *, char **, char **)
Wait input.
Definition: ui.c:160
DLL_API void edax_hint_next(Hint *)
hint command. Gets hint one by one. If there are no more hints, hint will be NOMOVE....
Definition: libedax.c:573
DLL_API void edax_book_new(const int, const int)
book new command.
Definition: libedax.c:759
DLL_API void edax_book_info(Book *)
book info command.
Definition: libedax.c:979
DLL_API int edax_get_disc(const int)
get current number of discs.
Definition: libedax.c:1478
DLL_API void edax_book_export(const char *)
book export command.
Definition: libedax.c:826
DLL_API void edax_enable_book_verbose(void)
enable book_verbose to get stdout by bprint.
Definition: libedax.c:1513
DLL_API void edax_setboard(const char *)
setboard command.
Definition: libedax.c:265
static void libedax_observer(Result *)
DLL_API void edax_redo(void)
redo command.
Definition: libedax.c:237
DLL_API int edax_board_get_square_color(const Board *, const int)
Get square color.
Definition: libedax.c:1543
DLL_API void edax_bench_get_result(BenchResult *)
Definition: libedax.c:468
DLL_API void edax_book_save(const char *)
book save command.
Definition: libedax.c:791
DLL_API void edax_init(void)
init command.
Definition: libedax.c:181
bool ui_switch(UI *, const char *)
Switch between different User Interface.
Definition: ui.c:25
DLL_API void edax_book_count_board_bestpath(Board *, Position *, const int, const int, const int)
count the number of best paths in book.
Definition: libedax.c:1018
DLL_API void edax_version(void)
version command.
Definition: libedax.c:609
DLL_API void edax_book_add_board_pre_process(void)
book add board preprocess.
Definition: libedax.c:1227
DLL_API void edax_book_feed_hash(void)
book feed-hash command.
Definition: libedax.c:1212
DLL_API void edax_bench(BenchResult *, int)
bench (a serie of low level tests). command.
Definition: libedax.c:452
DLL_API void edax_book_extract(const char *)
book extract command.
Definition: libedax.c:1111
DLL_API const char * edax_opening(void)
opening command.
Definition: libedax.c:639
void ui_init_ggs(UI *)
ui_init_ggs
Definition: ggs.c:1390
void ui_event_init(UI *)
Create a new Othello User Interface.
Definition: ui.c:206
void ui_event_free(UI *)
Free events.
Definition: ui.c:220
DLL_API void edax_base_correct(const char *, const int)
base correct command.
Definition: libedax.c:1291
DLL_API void edax_book_add_board(const Board *)
book add board.
Definition: libedax.c:1246
DLL_API void edax_save(const char *)
save command.
Definition: libedax.c:216
DLL_API void edax_book_count_bestpath(Board *, Position *)
count the number of best paths in book.
Definition: libedax.c:1005
DLL_API void edax_base_problem(const char *, const int, const char *)
base problem command.
Definition: libedax.c:1258
DLL_API const char * edax_ouverture(void)
ouverture command.
Definition: libedax.c:653
DLL_API void edax_book_store(void)
book store command.
Definition: libedax.c:688
DLL_API void libedax_terminate(void)
edax terminate function for library use.
Definition: libedax.c:91
void ui_init_edax(UI *)
initialize edax protocol.
Definition: edax.c:137
void book_cmd_post_process(UI *)
post-process of book command.
Definition: libedax.c:678
void ui_free_libedax(UI *)
free resources used by libedax api.
Definition: libedax.c:134
void ui_free_nboard(UI *)
free resources used by edax protocol
Definition: nboard.c:101
DLL_API void edax_book_subtree(void)
book subtree command.
Definition: libedax.c:928
void ui_init_nboard(UI *)
initialize edax protocol
Definition: nboard.c:80
DLL_API void edax_book_off(void)
book off command.
Definition: libedax.c:715
DLL_API void edax_book_on(void)
book on command.
Definition: libedax.c:702
DLL_API void edax_stop(void)
stop command.
Definition: libedax.c:598
DLL_API void edax_disable_book_verbose(void)
disable book_verbose not to get stdout by bprint.
Definition: libedax.c:1523
DLL_API void edax_go(void)
go command.
Definition: libedax.c:497
void ui_loop_xboard(UI *)
Loop event.
Definition: xboard.c:440
DLL_API void edax_rotate(const int)
rotate command.
Definition: libedax.c:308
DLL_API void edax_symetry(const int)
symetry command.
Definition: libedax.c:333