-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmariai.h
62 lines (56 loc) · 1.4 KB
/
mariai.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef MARIAI_H
#define MARIAI_H
#include "board.h"
#include "common.h"
#include "draw.h"
class Node {
public:
Node(Node *p, Coords g, Stone s, int d)
: Q(100.), reward(0), win(0), visit(0), prev(p), coords(g), turn(s),
depth(d), leaf(true) {}
~Node() {}
public:
float Q;
float reward;
int win;
int visit;
Node *prev;
Coords coords;
Stone turn;
int depth;
bool leaf;
vector<Node> children;
vector<uint8_t> children_iQ;
};
class Mariai {
public:
Mariai(Board *b, Draw *d);
~Mariai();
Board *gb();
Draw *gd();
float calc_ucb(const Node *node);
void sort_children_by_Q(Node *node);
Node *get_most_visited_child(Node *node);
void init_tree(Node *root, Board &b);
void run_mcts(Node *root, Board &b);
tuple<bool, Node *> select_path(Node *node, Board &vg);
void expand_node(Node *node, Board &vg);
bool backpropagation(Node *node, Node *root, Stone turn, bool tied);
void fast_rollout(Board &vg, bool quit);
void insert_node(Node *node, Coords q, Stone s);
bool is_expandable(Node *node);
bool move_and_check_quit(Node *node, Board &vg);
void print_tree(Node *node, int set_width, ofstream &fout);
Coords pick_best(Node *node);
Coords next_move();
void show_progress();
void dump_progress(float progress);
VecCoords gen_candy(Board &b);
Qdist get_dist_Q();
private:
Board *p_board;
Draw *p_draw;
int it;
vector<float> Q_values;
};
#endif