UCB1AMAF: Rationale for zero gp_eqex
[pachi.git] / uct / tree.h
blobb09f799d518a4879ee8034a4fd605ba833adcd80
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;
34 /*** From here on, struct is saved/loaded from opening book */
36 int depth; // just for statistics
38 coord_t coord;
40 struct move_stats u;
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
45 int hints;
48 struct tree {
49 struct board *board;
50 struct tree_node *root;
51 struct board_symmetry root_symmetry;
53 // Statistics
54 int max_depth;
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);
72 #endif