10 typedef enum parse_code (*engine_notify_t
)(struct engine
*e
, struct board
*b
, int id
, char *cmd
, char *args
, char **reply
);
11 typedef void (*engine_board_print_t
)(struct engine
*e
, struct board
*b
, FILE *f
);
12 typedef char *(*engine_notify_play_t
)(struct engine
*e
, struct board
*b
, struct move
*m
, char *enginearg
);
13 typedef char *(*engine_undo_t
)(struct engine
*e
, struct board
*b
);
14 typedef char *(*engine_result_t
)(struct engine
*e
, struct board
*b
);
15 typedef char *(*engine_chat_t
)(struct engine
*e
, struct board
*b
, bool in_game
, char *from
, char *cmd
);
16 /* Generate a move. If pass_all_alive is true, <pass> shall be generated only
17 * if all stones on the board can be considered alive, without regard to "dead"
18 * considered stones. */
19 typedef coord_t
*(*engine_genmove_t
)(struct engine
*e
, struct board
*b
, struct time_info
*ti
, enum stone color
, bool pass_all_alive
);
20 typedef char *(*engine_genmoves_t
)(struct engine
*e
, struct board
*b
, struct time_info
*ti
, enum stone color
,
21 char *args
, bool pass_all_alive
, void **stats_buf
, int *stats_size
);
22 /* Evaluate feasibility of player @color playing at all free moves. Will
23 * simulate each move from b->f[i] for time @ti, then set
24 * 1-max(opponent_win_likelihood) in vals[i]. */
25 typedef void (*engine_evaluate_t
)(struct engine
*e
, struct board
*b
, struct time_info
*ti
, floating_t
*vals
, enum stone color
);
26 /* One dead group per queued move (coord_t is (ab)used as group_t). */
27 typedef void (*engine_dead_group_list_t
)(struct engine
*e
, struct board
*b
, struct move_queue
*mq
);
28 /* Pause any background thinking being done, but do not tear down
29 * any data structures yet. */
30 typedef void (*engine_stop_t
)(struct engine
*e
);
31 /* e->data and e will be free()d by caller afterwards. */
32 typedef void (*engine_done_t
)(struct engine
*e
);
35 typedef float (*engine_owner_map_t
)(struct engine
*e
, struct board
*b
, coord_t c
);
36 typedef void (*engine_best_moves_t
)(struct engine
*e
, struct board
*b
, enum stone color
);
37 typedef void (*engine_live_gfx_hook_t
)(struct engine
*e
);
39 /* This is engine data structure. A new engine instance is spawned
40 * for each new game during the program lifetime. */
45 /* If set, do not reset the engine state on clear_board. */
48 engine_notify_t notify
;
49 engine_board_print_t board_print
;
50 engine_notify_play_t notify_play
;
53 engine_result_t result
;
54 engine_genmove_t genmove
;
55 engine_genmoves_t genmoves
;
56 engine_evaluate_t evaluate
;
57 engine_dead_group_list_t dead_group_list
;
60 engine_owner_map_t owner_map
;
61 engine_best_moves_t best_moves
;
62 engine_live_gfx_hook_t live_gfx_hook
;
67 engine_board_print(struct engine
*e
, struct board
*b
, FILE *f
)
69 (e
->board_print
? e
->board_print(e
, b
, f
) : board_print(b
, f
));
73 engine_done(struct engine
*e
)
75 if (e
->done
) e
->done(e
);
76 if (e
->data
) free(e
->data
);