Moggy: Move atari check to global_atari_check()
[pachi.git] / uct / tree.h
blob1f6f19ed20b98ef32880eef2c31d41355e53e742
1 #ifndef ZZGO_UCT_TREE_H
2 #define ZZGO_UCT_TREE_H
4 #include <stdbool.h>
5 #include "move.h"
7 struct board;
9 struct tree_node {
11 * +------+
12 * | node |
13 * +------+
14 * / <- parent
15 * +------+ v- sibling +------+
16 * | node | ------------ | node |
17 * +------+ +------+
18 * | <- children |
19 * +------+ +------+ +------+ +------+
20 * | node | - | node | | node | - | node |
21 * +------+ +------+ +------+ +------+
23 struct tree_node *parent, *sibling, *children;
25 coord_t coord;
26 int playouts; // # of playouts coming through this node
27 int wins; // # of wins coming through this node
28 float value; // wins/playouts
31 struct tree {
32 struct tree_node *root;
33 struct board *board;
36 struct tree *tree_init(struct board *board);
37 void tree_done(struct tree *tree);
38 void tree_dump(struct tree *tree);
40 void tree_expand_node(struct tree *tree, struct tree_node *node, struct board *b);
41 void tree_delete_node(struct tree_node *node);
42 void tree_promote_node(struct tree *tree, struct tree_node *node);
43 bool tree_leaf_node(struct tree_node *node);
44 void tree_uct_update(struct tree_node *node, int result);
46 #endif