1 #ifndef ZZGO_UCT_INTERNAL_H
2 #define ZZGO_UCT_INTERNAL_H
4 #include <signal.h> // sig_atomic_t
16 /* Internal UCT structures */
19 /* Internal engine state. */
27 bool playout_amaf
, playout_amaf_nakade
;
29 int playout_amaf_cutoff
;
33 unsigned long max_tree_size
;
37 enum uct_thread_model
{
38 TM_ROOT
, /* Root parallelization. */
39 TM_TREE
, /* Tree parallelization w/o virtual loss. */
40 TM_TREEVL
, /* Tree parallelization with virtual loss. */
55 int random_policy_chance
;
60 struct uct_policy
*policy
;
61 struct uct_policy
*random_policy
;
62 struct playout_policy
*playout
;
63 struct uct_prior
*prior
;
65 /* Used within frame of single genmove. */
66 struct board_ownermap ownermap
;
68 /* Game state - maintained by setup_state(), reset_state(). */
72 #define UDEBUGL(n) DEBUGL_(u->debug_level, n)
74 extern volatile sig_atomic_t uct_halt
;
75 extern __thread
int thread_id
;
77 bool uct_pass_is_safe(struct uct
*u
, struct board
*b
, enum stone color
, bool pass_all_alive
);
80 typedef struct tree_node
*(*uctp_choose
)(struct uct_policy
*p
, struct tree_node
*node
, struct board
*b
, enum stone color
);
81 typedef struct tree_node
*(*uctp_winner
)(struct uct_policy
*p
, struct tree
*tree
, struct tree_node
*node
);
82 typedef float (*uctp_evaluate
)(struct uct_policy
*p
, void **state
, struct tree
*tree
, struct tree_node
*node
, int parity
);
83 typedef struct tree_node
*(*uctp_descend
)(struct uct_policy
*p
, void **state
, struct tree
*tree
, struct tree_node
*node
, int parity
, bool allow_pass
);
84 typedef void (*uctp_prior
)(struct uct_policy
*p
, struct tree
*tree
, struct tree_node
*node
, struct board
*b
, enum stone color
, int parity
);
85 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
);
91 uctp_evaluate evaluate
;