1 #ifndef ZZGO_UCT_POLICY_GENERIC_H
2 #define ZZGO_UCT_POLICY_GENERIC_H
4 /* Some default policy routines and templates. */
7 #include "uct/internal.h"
12 struct tree_node
*uctp_generic_choose(struct uct_policy
*p
, struct tree_node
*node
, struct board
*b
, enum stone color
);
13 struct tree_node
*uctp_generic_winner(struct uct_policy
*p
, struct tree
*tree
, struct tree_node
*node
);
16 /* Some generic stitching for tree descent. */
18 #define uctd_try_node_children(node, allow_pass, ni, urgency) \
19 /* XXX: Stack overflow danger on big boards? */ \
20 struct tree_node *nbest[512] = { node->children }; int nbests = 1; \
21 float best_urgency = -9999; \
23 for (struct tree_node *ni = node->children; ni; ni = ni->sibling) { \
25 /* Do not consider passing early. */ \
26 if (unlikely((!allow_pass && is_pass(ni->coord)) || (ni->hints & TREE_HINT_INVALID))) \
29 /* ...your urgency computation code goes here... */
31 #define uctd_set_best_child(ni, urgency) \
32 if (urgency - best_urgency > __FLT_EPSILON__) { /* urgency > best_urgency */ \
33 best_urgency = urgency; nbests = 0; \
35 if (urgency - best_urgency > -__FLT_EPSILON__) { /* urgency >= best_urgency */ \
36 /* We want to always choose something else than a pass \
37 * in case of a tie. pass causes degenerative behaviour. */ \
38 if (nbests == 1 && is_pass(nbest[0]->coord)) { \
41 nbest[nbests++] = ni; \
45 #define uctd_get_best_child() nbest[fast_random(nbests)]