UCB1: First Play Urgency support
[pachi.git] / uct / tree.h
blob0e6dd882e65750f83c853920b0072f4c0e4405bd
1 #ifndef ZZGO_UCT_TREE_H
2 #define ZZGO_UCT_TREE_H
4 #include <stdbool.h>
5 #include "move.h"
7 struct board;
8 struct uct_policy;
11 * +------+
12 * | node |
13 * +------+
14 * / <- parent
15 * +------+ v- sibling +------+
16 * | node | ------------ | node |
17 * +------+ +------+
18 * | <- children |
19 * +------+ +------+ +------+ +------+
20 * | node | - | node | | node | - | node |
21 * +------+ +------+ +------+ +------+
24 struct tree_node {
25 hash_t hash;
26 struct tree_node *parent, *sibling, *children;
27 int depth; // just for statistics
29 coord_t coord;
31 int playouts; // # of playouts coming through this node
32 int wins; // # of wins coming through this node
33 float value; // wins/playouts
36 struct tree {
37 struct tree_node *root;
38 struct board *board;
40 // Statistics
41 int max_depth;
44 struct tree *tree_init(struct board *board, enum stone color);
45 void tree_done(struct tree *tree);
46 void tree_dump(struct tree *tree);
48 void tree_expand_node(struct tree *tree, struct tree_node *node, struct board *b, enum stone color, int radar, struct uct_policy *policy);
49 void tree_delete_node(struct tree *tree, struct tree_node *node);
50 void tree_promote_node(struct tree *tree, struct tree_node *node);
51 bool tree_leaf_node(struct tree_node *node);
53 #endif