Pattern FEAT_PATTERN3: Introduce, use by default inst. of FEAT_SPATIAL in matchfast
[pachi.git] / uct / internal.h
blobf56ea0ab42e181b468429c234ed323b5c09af027
1 #ifndef ZZGO_UCT_INTERNAL_H
2 #define ZZGO_UCT_INTERNAL_H
4 #include <signal.h> // sig_atomic_t
6 #include "debug.h"
7 #include "move.h"
8 #include "ownermap.h"
9 #include "playout.h"
11 struct tree;
12 struct tree_node;
13 struct uct_policy;
14 struct uct_prior;
16 /* Internal UCT structures */
19 /* Internal engine state. */
20 struct uct {
21 int debug_level;
22 int games, gamelen;
23 float resign_ratio;
24 float loss_threshold;
25 bool pass_all_alive;
26 int expand_p;
27 bool playout_amaf, playout_amaf_nakade;
28 bool amaf_prior;
29 int playout_amaf_cutoff;
30 int dumpthres;
31 int force_seed;
32 bool no_book;
34 int threads;
35 enum uct_thread_model {
36 TM_NONE, /* <=> threads == 0 */
37 TM_ROOT, /* Root parallelization. */
38 TM_TREE, /* Tree parallelization w/o virtual loss. */
39 TM_TREEVL, /* Tree parallelization with virtual loss. */
40 } thread_model;
41 bool parallel_tree;
42 bool virtual_loss;
44 int dynkomi;
45 int dynkomi_mask;
47 float val_scale;
48 int val_points;
49 bool val_extra;
51 int random_policy_chance;
52 int root_heuristic;
54 char *banner;
56 struct uct_policy *policy;
57 struct uct_policy *random_policy;
58 struct playout_policy *playout;
59 struct uct_prior *prior;
61 /* Used within frame of single genmove. */
62 struct board_ownermap ownermap;
64 /* Game state - maintained by setup_state(), reset_state(). */
65 struct tree *t;
68 #define UDEBUGL(n) DEBUGL_(u->debug_level, n)
70 extern volatile sig_atomic_t uct_halt;
71 extern __thread int thread_id;
73 bool uct_pass_is_safe(struct uct *u, struct board *b, enum stone color, bool pass_all_alive);
76 typedef struct tree_node *(*uctp_choose)(struct uct_policy *p, struct tree_node *node, struct board *b, enum stone color);
77 typedef float (*uctp_evaluate)(struct uct_policy *p, void **state, struct tree *tree, struct tree_node *node, int parity);
78 typedef struct tree_node *(*uctp_descend)(struct uct_policy *p, void **state, struct tree *tree, struct tree_node *node, int parity, bool allow_pass);
79 typedef void (*uctp_prior)(struct uct_policy *p, struct tree *tree, struct tree_node *node, struct board *b, enum stone color, int parity);
80 typedef void (*uctp_update)(struct uct_policy *p, struct tree *tree, struct tree_node *node, enum stone node_color, enum stone player_color, struct playout_amafmap *amaf, float result);
82 struct uct_policy {
83 struct uct *uct;
84 uctp_choose choose;
85 uctp_evaluate evaluate;
86 uctp_descend descend;
87 uctp_update update;
88 uctp_prior prior;
89 bool wants_amaf;
90 void *data;
93 #endif