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 
31 typedef struct UI {
32  Play play[2];
33  Book book[1];
34  struct GGSClient *ggs;
35  bool is_same_play;
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*);
43 } UI;
44 
45 bool ui_switch(UI*, const char*);
46 
47 void ui_event_init(UI*);
48 bool ui_event_peek(UI*, char**, char**);
49 void ui_event_wait(UI*, char**, char**);
50 bool ui_event_exist(UI*);
51 void ui_event_free(UI*);
52 
53 void ui_init_edax(UI*);
54 void ui_loop_edax(UI*);
55 void ui_free_edax(UI*);
56 
57 void ui_init_gtp(UI*);
58 void ui_loop_gtp(UI*);
59 void ui_free_gtp(UI*);
60 
61 void ui_init_nboard(UI*);
62 void ui_loop_nboard(UI*);
63 void ui_free_nboard(UI*);
64 
65 void ui_init_xboard(UI*);
66 void ui_loop_xboard(UI*);
67 void ui_free_xboard(UI*);
68 
69 void ui_init_ggs(UI*);
70 void ui_loop_ggs(UI*);
71 void ui_free_ggs(UI*);
72 
73 void ui_init_cassio(UI*);
74 void ui_loop_cassio(UI*);
75 void ui_free_cassio(UI*);
76 
77 void ui_book_init(UI*);
78 
79 // add for libedax by lavox. 2018/1/19
80 // api functions
81 DLL_API void libedax_initialize(int, char**);
83 DLL_API void edax_init();
84 DLL_API void edax_new();
85 DLL_API void edax_load(const char*);
86 DLL_API void edax_save(const char*);
87 DLL_API void edax_undo();
88 DLL_API void edax_redo();
89 DLL_API void edax_mode(const int);
90 DLL_API void edax_setboard(const char*);
91 DLL_API void edax_setboard_from_obj(const Board*, const int);
92 DLL_API void edax_vmirror();
93 DLL_API void edax_hmirror();
94 DLL_API void edax_rotate(const int);
95 DLL_API void edax_symetry(const int);
96 DLL_API void edax_play(char*);
97 DLL_API void edax_force(char*);
98 DLL_API void edax_go();
99 DLL_API void edax_hint(const int, HintList*);
102 DLL_API void edax_stop();
103 DLL_API int edax_move(const char*);
104 DLL_API const char* edax_opening();
105 DLL_API const char* edax_ouverture();
106 DLL_API void edax_book_store();
107 DLL_API void edax_book_on();
108 DLL_API void edax_book_off();
109 DLL_API void edax_book_randomness(const int);
110 DLL_API void edax_book_depth(const int);
111 DLL_API void edax_book_new(const int, const int);
112 DLL_API void edax_book_load(const char*);
113 DLL_API void edax_book_save(const char*);
114 DLL_API void edax_book_import(const char*);
115 DLL_API void edax_book_export(const char*);
116 DLL_API void edax_book_merge(const char*);
117 DLL_API void edax_book_fix();
120 DLL_API void edax_book_prune();
124 DLL_API void edax_book_verbose(const int);
125 DLL_API void edax_book_add(const char*);
126 DLL_API void edax_book_check(const char*);
127 DLL_API void edax_book_extract(const char*);
128 DLL_API void edax_book_deviate(int, int);
129 DLL_API void edax_book_enhance(int, int);
130 DLL_API void edax_book_fill(int);
131 DLL_API void edax_book_play();
134 DLL_API void edax_base_problem(const char*, const int, const char*);
135 DLL_API void edax_base_tofen(const char*, const int, const char*);
136 DLL_API void edax_base_correct(const char*, const int);
137 DLL_API void edax_base_complete(const char*);
138 DLL_API void edax_base_convert(const char*, const char*);
139 DLL_API void edax_base_unique(const char*, const char*);
140 DLL_API void edax_set_option(const char*, const char*);
141 
142 DLL_API char* edax_get_moves(char*);
144 DLL_API int edax_can_move();
148 DLL_API int edax_get_disc(const int);
149 DLL_API int edax_get_mobility_count(const int);
150 
151 // internal functions
152 static void libedax_observer(Result*);
153 void ui_init_libedax(UI*);
154 void ui_free_libedax(UI*);
155 void auto_go();
156 
157 void book_cmd_pre_process(UI*);
159 
160 #endif
161 
void ui_free_libedax(UI *)
free resources used by libedax api.
Definition: libedax.c:133
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:1132
DLL_API void edax_book_store()
book store command.
Definition: libedax.c:604
DLL_API void edax_vmirror()
vmirror command.
Definition: libedax.c:286
DLL_API void edax_load(const char *)
load command.
Definition: libedax.c:204
DLL_API void edax_rotate(const int)
rotate command.
Definition: libedax.c:307
Book book[1]
Definition: ui.h:33
The opening book.
Definition: book.h:25
void ui_init_xboard(UI *)
initialize xboard protocol.
Definition: xboard.c:72
void ui_free_edax(UI *)
free resources used by edax protocol.
Definition: edax.c:157
DLL_API void edax_book_randomness(const int)
book randomness command.
Definition: libedax.c:645
DLL_API void edax_symetry(const int)
symetry command.
Definition: libedax.c:332
void ui_loop_edax(UI *)
Loop event.
Definition: edax.c:284
bool ui_switch(UI *, const char *)
Switch between different User Interface.
Definition: ui.c:25
void ui_free_xboard(UI *)
free resources used by xboard protocol.
Definition: xboard.c:97
void ui_free_nboard(UI *)
free resources used by edax protocol
Definition: nboard.c:101
DLL_API void edax_book_export(const char *)
book export command.
Definition: libedax.c:742
DLL_API void edax_book_show(Position *)
book show command.
Definition: libedax.c:864
DLL_API int edax_get_disc(const int)
get current number of discs.
Definition: libedax.c:1319
Definition: play.h:25
void ui_loop_cassio(UI *)
DLL_API void edax_setboard(const char *)
setboard command.
Definition: libedax.c:264
DLL_API void edax_play(char *)
play command.
Definition: libedax.c:346
DLL_API void edax_book_info(Book *)
book info command.
Definition: libedax.c:881
void(* loop)(struct UI *)
Definition: ui.h:41
struct UI UI
DLL_API void libedax_terminate()
edax terminate function for library use.
Definition: libedax.c:90
DLL_API void edax_save(const char *)
save command.
Definition: libedax.c:215
DLL_API void edax_book_verbose(const int)
book verbose command.
Definition: libedax.c:911
void ui_init_ggs(UI *)
ui_init_ggs
Definition: ggs.c:1390
Definition: move.h:20
DLL_API void edax_book_merge(const char *)
book merge command.
Definition: libedax.c:757
DLL_API int edax_is_game_over()
check if the current game is over.
Definition: libedax.c:1262
DLL_API int edax_move(const char *)
user move command.
Definition: libedax.c:537
DLL_API void edax_book_subtree()
book subtree command.
Definition: libedax.c:844
DLL_API void edax_book_on()
book on command.
Definition: libedax.c:618
int type
Definition: ui.h:36
void ui_init_nboard(UI *)
initialize edax protocol
Definition: nboard.c:80
void ui_init_cassio(UI *)
DLL_API void edax_hmirror()
hmirror command.
Definition: libedax.c:296
void ui_event_init(UI *)
Create a new Othello User Interface.
Definition: ui.c:206
Definition: board.h:26
DLL_API void edax_book_fix()
book fix command.
Definition: libedax.c:776
DLL_API void edax_book_check(const char *)
book check command.
Definition: libedax.c:952
DLL_API void edax_hint(const int, HintList *)
hint command.
Definition: libedax.c:486
Definition: event.h:18
DLL_API int edax_get_mobility_count(const int)
get current number of legal moves.
Definition: libedax.c:1331
DLL_API void edax_get_board(Board *)
get current board.
Definition: libedax.c:1297
void book_cmd_post_process(UI *)
post-process of book command.
Definition: libedax.c:594
bool ui_event_exist(UI *)
ui_event_exist
Definition: ui.c:189
DLL_API int edax_get_current_player()
get current player.
Definition: libedax.c:1309
struct GGSClient * ggs
Definition: ui.h:34
void ui_free_gtp(UI *)
free resources used by edax protocol
Definition: gtp.c:115
int mode
Definition: ui.h:37
DLL_API void edax_book_import(const char *)
book import command.
Definition: libedax.c:722
bool ui_event_peek(UI *, char **, char **)
Wait input.
Definition: ui.c:160
DLL_API void edax_force(char *)
force command.
Definition: libedax.c:360
DLL_API void edax_book_depth(const int)
book depth command.
Definition: libedax.c:659
DLL_API void edax_book_save(const char *)
book save command.
Definition: libedax.c:707
void auto_go()
auto go with regard to mode.
Definition: libedax.c:144
DLL_API void edax_mode(const int)
mode command.
Definition: libedax.c:248
Edax play control - header file.
Definition: search.h:81
void ui_init_libedax(UI *)
initialize libedax api.
Definition: libedax.c:113
DLL_API void edax_book_prune()
book prune command.
Definition: libedax.c:826
DLL_API void edax_setboard_from_obj(const Board *, const int)
setboard command with board object.
Definition: libedax.c:276
void ui_init_gtp(UI *)
initialize edax protocol
Definition: gtp.c:93
static void libedax_observer(Result *)
DLL_API void edax_book_enhance(int, int)
book enhance command.
Definition: libedax.c:1019
void ui_loop_gtp(UI *)
Loop event.
Definition: gtp.c:127
DLL_API void edax_base_problem(const char *, const int, const char *)
base problem command.
Definition: libedax.c:1099
DLL_API void edax_book_extract(const char *)
book extract command.
Definition: libedax.c:980
void(* init)(struct UI *)
Definition: ui.h:40
bool is_same_play
Definition: ui.h:35
DLL_API void edax_hint_prepare()
hint command. Call edax_hint_next after calling this function.
Definition: libedax.c:497
void ui_init_edax(UI *)
initialize edax protocol.
Definition: edax.c:137
DLL_API void edax_stop()
stop command.
Definition: libedax.c:521
DLL_API void edax_book_feed_hash()
book feed-hash command.
Definition: libedax.c:1081
DLL_API void edax_book_off()
book off command.
Definition: libedax.c:631
DLL_API int edax_can_move()
check if the current player can move.
Definition: libedax.c:1271
DLL_API void edax_get_last_move(Move *)
get last move.
Definition: libedax.c:1281
Definition: search.h:62
DLL_API void edax_base_unique(const char *, const char *)
base unique command.
Definition: libedax.c:1198
DLL_API void libedax_initialize(int, char **)
edax init function for library use.
Definition: libedax.c:40
void(* free)(struct UI *)
Definition: ui.h:42
Play play[2]
Definition: ui.h:32
Definition: search.h:41
DLL_API void edax_redo()
redo command.
Definition: libedax.c:236
DLL_API void edax_book_deepen()
book deepen command. caution: Currently, this function does not work correctly.
Definition: libedax.c:1067
Definition: ui.h:31
DLL_API void edax_base_convert(const char *, const char *)
base convert command.
Definition: libedax.c:1182
void ui_loop_nboard(UI *)
Loop event.
Definition: nboard.c:113
DLL_API void edax_book_correct()
book correct command.
Definition: libedax.c:808
void ui_book_init(UI *)
void ui_free_cassio(UI *)
DLL_API void edax_init()
init command.
Definition: libedax.c:180
void ui_free_ggs(UI *)
ui_free_ggs
Definition: ggs.c:1599
DLL_API const char * edax_opening()
opening command.
Definition: libedax.c:555
DLL_API void edax_base_complete(const char *)
base complete command.
Definition: libedax.c:1162
void ui_loop_xboard(UI *)
Loop event.
Definition: xboard.c:440
#define DLL_API
Definition: ui.h:25
A position stored in the book.
Definition: book.h:76
Definition: ggs.c:146
DLL_API const char * edax_ouverture()
ouverture command.
Definition: libedax.c:569
DLL_API void edax_book_add(const char *)
book add command.
Definition: libedax.c:933
DLL_API void edax_hint_next(Hint *)
hint command. Gets hint one by one. If there are no more hints, hint will be NOMOVE. Call edax_hint_prepare before calling this function.
Definition: libedax.c:511
void ui_event_wait(UI *, char **, char **)
Wait input.
Definition: ui.c:147
void book_cmd_pre_process(UI *)
pre-process of book command.
Definition: libedax.c:583
DLL_API void edax_undo()
undo command.
Definition: libedax.c:225
DLL_API void edax_set_option(const char *, const char *)
set (option) command.
Definition: libedax.c:1223
DLL_API void edax_book_load(const char *)
book load command.
Definition: libedax.c:691
DLL_API void edax_book_fill(int)
book fill command.
Definition: libedax.c:1037
DLL_API void edax_book_new(const int, const int)
book new command.
Definition: libedax.c:675
void ui_loop_ggs(UI *)
ui_loop_ggs
Definition: ggs.c:1418
DLL_API void edax_go()
go command.
Definition: libedax.c:471
DLL_API void edax_book_play()
book play command.
Definition: libedax.c:1052
DLL_API void edax_new()
new command.
Definition: libedax.c:193
DLL_API void edax_book_deviate(int, int)
book deviate command.
Definition: libedax.c:1000
DLL_API char * edax_get_moves(char *)
get moves of the current game.
Definition: libedax.c:1244
DLL_API void edax_book_negamax()
book negamax command.
Definition: libedax.c:793
DLL_API void edax_base_tofen(const char *, const int, const char *)
base tofen command.
Definition: libedax.c:1116