Moggy: Fix CUT1 on the edge or in ponnuki shape
[pachi.git] / uct / tree.h
blob90d30f3017a58c2c8b94ec694a4410cdc36e3068
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
34 int hints;
37 struct tree {
38 struct tree_node *root;
39 struct board *board;
41 // Statistics
42 int max_depth;
45 struct tree *tree_init(struct board *board, enum stone color);
46 void tree_done(struct tree *tree);
47 void tree_dump(struct tree *tree, int thres);
49 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);
50 void tree_delete_node(struct tree *tree, struct tree_node *node);
51 void tree_promote_node(struct tree *tree, struct tree_node *node);
52 bool tree_leaf_node(struct tree_node *node);
54 #endif