board_group_rmlib(): Zero out emptied spots in lib[]
[pachi.git] / uct / tree.h
blobd9f5c9a0f29028b8d55bb9cfb02af838634160ad
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 move_stats {
25 int playouts; // # of playouts coming through this node
26 int wins; // # of wins coming through this node
27 float value; // wins/playouts
30 struct tree_node {
31 hash_t hash;
32 struct tree_node *parent, *sibling, *children;
33 int depth; // just for statistics
35 coord_t coord;
37 struct move_stats u;
38 struct move_stats prior;
39 /* XXX: Should be way for policies to add their own stats */
40 struct move_stats amaf;
41 int hints;
44 struct tree {
45 struct tree_node *root;
46 struct board *board;
48 // Statistics
49 int max_depth;
52 struct tree *tree_init(struct board *board, enum stone color);
53 void tree_done(struct tree *tree);
54 void tree_dump(struct tree *tree, int thres);
56 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);
57 void tree_delete_node(struct tree *tree, struct tree_node *node);
58 void tree_promote_node(struct tree *tree, struct tree_node *node);
59 bool tree_leaf_node(struct tree_node *node);
60 void tree_update_node_value(struct tree_node *node, bool add_amaf);
62 #endif