UCT: Keep prior moves in separate stats
[pachi.git] / uct / tree.h
blobd1b4238700b890546329606c2a611ad17ba80024
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 int hints;
42 struct tree {
43 struct tree_node *root;
44 struct board *board;
46 // Statistics
47 int max_depth;
50 struct tree *tree_init(struct board *board, enum stone color);
51 void tree_done(struct tree *tree);
52 void tree_dump(struct tree *tree, int thres);
54 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);
55 void tree_delete_node(struct tree *tree, struct tree_node *node);
56 void tree_promote_node(struct tree *tree, struct tree_node *node);
57 bool tree_leaf_node(struct tree_node *node);
59 #endif