summaryrefslogtreecommitdiff
path: root/include/uci/state.h
blob: 51207f35f4047ce2f6c08ec9ec60094eeebc85f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef UCI_STATE_H
#define UCI_STATE_H

#include "ipc/go_args.h"
#include "ipc/moves.h"
#include "bitboard.h"

typedef struct {
  char *data;
  int length;
} str_t;

typedef bool check_t;
typedef int spin_t;
typedef int combo_t;
// the button isn't actually a value thing
// it's more like an event.
// so we parse a button type, we set this to true, handle it
// then set it to false again
typedef bool button_t;

typedef struct {
  char **combination;
  int count;
  int default_index;
} option_combo_setting_t;
typedef struct {
  int min;
  int max;
  int default_value;
} option_spin_setting_t;
enum { OPTION_SPIN, OPTION_COMBO, OPTION_CHECK, OPTION_STRING, OPTION_BUTTON };
typedef struct {
  char option_name[32];
  int type;
  union {
    option_combo_setting_t combo;
    option_spin_setting_t spin;
    bool check_default;
    const char *string_default;
  } data;
  union {
    combo_t *combo;
    spin_t *spin;
    check_t *check;
    str_t *string;
    button_t *button;
  } value;
} option_setting_t;

void option_setting_combo(
  option_setting_t *target,
  char *option_name,
  char **combinations,
  int combinations_count,
  int default_index,
  combo_t *combo
);
void option_setting_spin(
  option_setting_t *target,
  const char *option_name,
  int min,
  int max,
  int default_value,
  spin_t *spin
);
void option_setting_check(
  option_setting_t *target,
  const char *option_name,
  bool default_value,
  check_t *check
);
void option_setting_string(
  option_setting_t *target,
  const char *option_name,
  const char *default_value,
  str_t *string
);
void option_setting_button(
  option_setting_t *target,
  const char *option_name,
  button_t *button
);
void print_setting(option_setting_t setting);

enum {
  UCI_SIGNAL_NONE,
  UCI_SIGNAL_QUIT,
  UCI_SIGNAL_GO,
  UCI_SIGNAL_GO_LOOP,
  UCI_SIGNAL_STOP, // game stop, don't stop the program
  
  UCI_SIGNAL_COUNT
};

typedef struct {
  size_t signal;
  size_t current_state;

  char name[32];
  char author[32];
  bool debug;

  go_args_t go_args;
  position_t position;
  ipc_moves_t *moves;
option_setting_t option_settings[11];

  // options
  spin_t threads;
  spin_t hash;
  button_t clear_hash;
  // str_t nalimovpath;
  // spin_t nalimovcache;
  // check_t ponder;
  // check_t ownbook;
  // spin_t multipv;
  check_t uci_showcurrline;
  check_t uci_showrefutations;
  check_t uci_limitstrength;
  spin_t uci_elo;
  check_t uci_analysemode;
  str_t uci_opponent;
  str_t uci_engineabout;
  // str_t uci_shredderbasespath;
  str_t uci_setpositionvalue;
} uci_state_t;

void uci_state_init(uci_state_t *state);
void uci_state_deinit(uci_state_t *state);
void apply_option(uci_state_t *state, char *name, char *buffer);

#endif // UCI_STATE_H