1 #ifndef ZZGO_UCT_TREE_H
2 #define ZZGO_UCT_TREE_H
15 * +------+ v- sibling +------+
16 * | node | ------------ | node |
19 * +------+ +------+ +------+ +------+
20 * | node | - | node | | node | - | node |
21 * +------+ +------+ +------+ +------+
25 int playouts
; // # of playouts coming through this node
26 int wins
; // # of wins coming through this node
27 float value
; // wins/playouts
32 struct tree_node
*parent
, *sibling
, *children
;
34 /*** From here on, struct is saved/loaded from opening book */
36 int depth
; // just for statistics
41 struct move_stats prior
;
42 /* XXX: Should be way for policies to add their own stats */
43 struct move_stats amaf
;
44 #define NODE_HINT_NOAMAF 0x80
50 struct tree_node
*root
;
51 struct board_symmetry root_symmetry
;
57 struct tree
*tree_init(struct board
*board
, enum stone color
);
58 void tree_done(struct tree
*tree
);
59 void tree_dump(struct tree
*tree
, int thres
);
60 void tree_save(struct tree
*tree
, struct board
*b
, int thres
);
61 void tree_load(struct tree
*tree
, struct board
*b
, enum stone color
);
62 struct tree
*tree_copy(struct tree
*tree
);
63 void tree_merge(struct tree
*dest
, struct tree
*src
);
65 void tree_expand_node(struct tree
*tree
, struct tree_node
*node
, struct board
*b
, enum stone color
, int radar
, struct uct_policy
*policy
, int parity
);
66 void tree_delete_node(struct tree
*tree
, struct tree_node
*node
);
67 void tree_promote_node(struct tree
*tree
, struct tree_node
*node
);
68 bool tree_promote_at(struct tree
*tree
, struct board
*b
, coord_t c
);
69 bool tree_leaf_node(struct tree_node
*node
);
70 void tree_update_node_value(struct tree_node
*node
);