README: Simplify strength info, add link to pachi-tr
[pachi.git] / engine.h
blob42c5923a717692ffb4a9b7b0b47707a817f07068
1 #ifndef PACHI_ENGINE_H
2 #define PACHI_ENGINE_H
4 #include "board.h"
5 #include "move.h"
6 #include "gtp.h"
8 struct move_queue;
10 typedef enum parse_code (*engine_notify)(struct engine *e, struct board *b, int id, char *cmd, char *args, char **reply);
11 typedef char *(*engine_notify_play)(struct engine *e, struct board *b, struct move *m, char *enginearg);
12 typedef char *(*engine_undo)(struct engine *e, struct board *b);
13 typedef char *(*engine_result)(struct engine *e, struct board *b);
14 typedef char *(*engine_chat)(struct engine *e, struct board *b, bool in_game, char *from, char *cmd);
15 /* Generate a move. If pass_all_alive is true, <pass> shall be generated only
16 * if all stones on the board can be considered alive, without regard to "dead"
17 * considered stones. */
18 typedef coord_t *(*engine_genmove)(struct engine *e, struct board *b, struct time_info *ti, enum stone color, bool pass_all_alive);
19 typedef char *(*engine_genmoves)(struct engine *e, struct board *b, struct time_info *ti, enum stone color,
20 char *args, bool pass_all_alive, void **stats_buf, int *stats_size);
21 /* Evaluate feasibility of player @color playing at all free moves. Will
22 * simulate each move from b->f[i] for time @ti, then set
23 * 1-max(opponent_win_likelihood) in vals[i]. */
24 typedef void (*engine_evaluate)(struct engine *e, struct board *b, struct time_info *ti, floating_t *vals, enum stone color);
25 /* One dead group per queued move (coord_t is (ab)used as group_t). */
26 typedef void (*engine_dead_group_list)(struct engine *e, struct board *b, struct move_queue *mq);
27 /* Pause any background thinking being done, but do not tear down
28 * any data structures yet. */
29 typedef void (*engine_stop)(struct engine *e);
30 /* e->data and e will be free()d by caller afterwards. */
31 typedef void (*engine_done)(struct engine *e);
33 /* This is engine data structure. A new engine instance is spawned
34 * for each new game during the program lifetime. */
35 struct engine {
36 char *name;
37 char *comment;
39 /* If set, do not reset the engine state on clear_board. */
40 bool keep_on_clear;
42 engine_notify notify;
43 board_cprint printhook;
44 engine_notify_play notify_play;
45 engine_chat chat;
46 engine_undo undo;
47 engine_result result;
48 engine_genmove genmove;
49 engine_genmoves genmoves;
50 engine_evaluate evaluate;
51 engine_dead_group_list dead_group_list;
52 engine_stop stop;
53 engine_done done;
54 void *data;
57 #endif