b163616d6e06bbf49be256e0d5463fe6d2241b10
[polyglot.git] / uci.h
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   sint64 tbhit_nb;
58   double time;
59   double speed;
60   double cpu;
61   double hash;
62   move_t current_line[LineSize];
63   
64   int root_move;
65   int root_move_pos;
66   int root_move_nb;
67   bool multipv_mode;
68   int multipvSP;
69   int multipvScore[MultiPVStackSize];
70   move_t multipvMove[MultiPVStackSize];
71   char info[UciStringSize];
72 } uci_t;
73
74 typedef enum {
75    EVENT_NONE         = 0,
76    EVENT_UCI          = 1 << 0,
77    EVENT_READY        = 1 << 1,
78    EVENT_STOP         = 1 << 2,
79    EVENT_MOVE         = 1 << 3,
80    EVENT_PV           = 1 << 4,
81    EVENT_DEPTH        = 1 << 5,
82    EVENT_DRAW         = 1 << 6,
83    EVENT_RESIGN       = 1 << 7,
84    EVENT_ILLEGAL_MOVE = 1 << 8,
85    EVENT_INFO         = 1 << 9
86 } dummy_event_t;
87
88 // variables
89
90 extern uci_t Uci[1];
91
92 // functions
93
94 extern void uci_open              (uci_t * uci, engine_t * engine);
95 extern void uci_send_isready      (uci_t * uci);
96 extern void uci_send_isready_sync (uci_t * uci);
97 extern void uci_send_stop         (uci_t * uci);
98 extern void uci_send_stop_sync    (uci_t * uci);
99 extern void uci_send_ucinewgame   (uci_t * uci);
100 extern void uci_set_threads       (uci_t * uci, int n);
101 extern const char * uci_thread_option(uci_t * uci);
102 extern bool uci_send_option       (uci_t * uci, const char option[], const char format[], ...);
103 extern void uci_close             (uci_t * uci);
104 extern void uci_clear             (uci_t * uci);
105 extern int  uci_parse             (uci_t * uci, const char string[]);
106
107 #endif // !defined UCI_H
108
109 // end of uci.h
110