1 
2 // uci.h
3 
4 #ifndef UCI_H
5 #define UCI_H
6 
7 // includes
8 
9 #include "board.h"
10 #include "engine.h"
11 #include "line.h"
12 #include "move.h"
13 #include "option.h"
14 #include "util.h"
15 
16 // macros
17 
18 // I need to make a uniform string type.
19 
20 #define UciStringSize 4096
21 #define MultiPVStackSize 256
22 
23 // types
24 
25 typedef struct {
26 
27   engine_t * engine;
28 
29   const char * name;
30   const char * author;
31 
32   option_list_t option[1];
33 
34   bool ready;
35   int ready_nb;
36 
37   bool searching;
38   int pending_nb;
39 
40   board_t board[1];
41 
42   int best_move;
43   int ponder_move;
44 
45   int score;
46   int depth;
47   int sel_depth;
48   move_t pv[LineSize];
49 
50   int best_score;
51   int best_depth;
52   int best_sel_depth;
53   move_t best_pv[LineSize];
54   char bestmove[UciStringSize];
55 
56   sint64 node_nb;
57   double time;
58   double speed;
59   double cpu;
60   double hash;
61   move_t current_line[LineSize];
62 
63   int root_move;
64   int root_move_pos;
65   int root_move_nb;
66   bool multipv_mode;
67   int multipvSP;
68   int multipvScore[MultiPVStackSize];
69   move_t multipvMove[MultiPVStackSize];
70   char info[UciStringSize];
71 } uci_t;
72 
73 typedef enum {
74    EVENT_NONE         = 0,
75    EVENT_UCI          = 1 << 0,
76    EVENT_READY        = 1 << 1,
77    EVENT_STOP         = 1 << 2,
78    EVENT_MOVE         = 1 << 3,
79    EVENT_PV           = 1 << 4,
80    EVENT_DEPTH        = 1 << 5,
81    EVENT_DRAW         = 1 << 6,
82    EVENT_RESIGN       = 1 << 7,
83    EVENT_ILLEGAL_MOVE = 1 << 8,
84    EVENT_INFO         = 1 << 9
85 } dummy_event_t;
86 
87 // variables
88 
89 extern uci_t Uci[1];
90 
91 // functions
92 
93 extern void uci_open              (uci_t * uci, engine_t * engine);
94 extern void uci_send_isready      (uci_t * uci);
95 extern void uci_send_isready_sync (uci_t * uci);
96 extern void uci_send_stop         (uci_t * uci);
97 extern void uci_send_stop_sync    (uci_t * uci);
98 extern void uci_send_ucinewgame   (uci_t * uci);
99 extern void uci_set_threads       (uci_t * uci, int n);
100 extern const char * uci_thread_option(uci_t * uci);
101 extern bool uci_send_option       (uci_t * uci, const char option[], const char format[], ...);
102 extern void uci_close             (uci_t * uci);
103 extern void uci_clear             (uci_t * uci);
104 extern int  uci_parse             (uci_t * uci, const char string[]);
105 
106 #endif // !defined UCI_H
107 
108 // end of uci.h
109 
110