UCT: Add missing parity correction for the prior function
[pachi.git] / uct / tree.h
blobe9bae917f77c16802bbbac147976d34b1e552064
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, int parity);
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