GTP kgs-time_settings: byoyomi_stones==0 for Japanese byoyomi
[pachi/json.git] / uct / policy / generic.h
bloba3b19401eecea4d0690bd4051c991ecb48e1b65d
1 #ifndef ZZGO_UCT_POLICY_GENERIC_H
2 #define ZZGO_UCT_POLICY_GENERIC_H
4 /* Some default policy routines and templates. */
6 #include "stone.h"
7 #include "uct/internal.h"
9 struct board;
10 struct tree_node;
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) { \
24 float urgency; \
25 /* Do not consider passing early. */ \
26 if (unlikely((!allow_pass && is_pass(ni->coord)) || (ni->hints & TREE_HINT_INVALID))) \
27 continue;
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; \
34 } \
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)) { \
39 nbests--; \
40 } \
41 nbest[nbests++] = ni; \
42 } \
45 #define uctd_get_best_child() nbest[fast_random(nbests)]
48 #endif