Add option territory_scoring to support Japanese rules.
[pachi.git] / uct / internal.h
blob13112657ae0923d570412f9185a947272610ab46
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 double best2_ratio, bestr_ratio;
26 bool pass_all_alive;
27 bool territory_scoring;
28 int expand_p;
29 bool playout_amaf, playout_amaf_nakade;
30 bool amaf_prior;
31 int playout_amaf_cutoff;
32 int dumpthres;
33 int force_seed;
34 bool no_book;
35 bool fast_alloc;
36 unsigned long max_tree_size;
37 int mercymin;
39 int threads;
40 enum uct_thread_model {
41 TM_ROOT, /* Root parallelization. */
42 TM_TREE, /* Tree parallelization w/o virtual loss. */
43 TM_TREEVL, /* Tree parallelization with virtual loss. */
44 } thread_model;
45 bool parallel_tree;
46 bool virtual_loss;
47 bool pondering_opt; /* User wants pondering */
48 bool pondering; /* Actually pondering now */
50 int fuseki_end;
51 int yose_start;
53 int dynkomi;
54 int dynkomi_mask;
55 int handicap_value;
57 float val_scale;
58 int val_points;
59 bool val_extra;
61 int random_policy_chance;
62 int root_heuristic;
64 char *banner;
66 struct uct_policy *policy;
67 struct uct_policy *random_policy;
68 struct playout_policy *playout;
69 struct uct_prior *prior;
71 /* Used within frame of single genmove. */
72 struct board_ownermap ownermap;
74 /* Game state - maintained by setup_state(), reset_state(). */
75 struct tree *t;
78 #define UDEBUGL(n) DEBUGL_(u->debug_level, n)
80 extern volatile sig_atomic_t uct_halt;
81 extern __thread int thread_id;
83 bool uct_pass_is_safe(struct uct *u, struct board *b, enum stone color, bool pass_all_alive);
86 typedef struct tree_node *(*uctp_choose)(struct uct_policy *p, struct tree_node *node, struct board *b, enum stone color, coord_t exclude);
87 typedef struct tree_node *(*uctp_winner)(struct uct_policy *p, struct tree *tree, struct tree_node *node);
88 typedef float (*uctp_evaluate)(struct uct_policy *p, void **state, struct tree *tree, struct tree_node *node, int parity);
89 typedef struct tree_node *(*uctp_descend)(struct uct_policy *p, void **state, struct tree *tree, struct tree_node *node, int parity, bool allow_pass);
90 typedef void (*uctp_prior)(struct uct_policy *p, struct tree *tree, struct tree_node *node, struct board *b, enum stone color, int parity);
91 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);
93 struct uct_policy {
94 struct uct *uct;
95 uctp_choose choose;
96 uctp_winner winner;
97 uctp_evaluate evaluate;
98 uctp_descend descend;
99 uctp_update update;
100 uctp_prior prior;
101 bool wants_amaf;
102 void *data;
105 #endif