-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolver.h
62 lines (52 loc) · 1.18 KB
/
Solver.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 DEF_WORKER
#define DEF_WORKER
#include <vector>
#include "Simulator.h"
class Node{
public:
Node(State &state, int player);
Node(State &state, int parentNode, int player, std::vector<Node> &nodes, int action);
bool isFullyExpanded() const;
void addChild(int child);
bool isRoot() const;
bool isTerminal() const;
int getN() const;
int getRandomAction();
State getState() const;
int getPlayer() const;
void representation() const;
void addReward(double reward);
void incrementEvaluation();
int getParent() const;
double getUCT(int nEvaluationParent) const;
unsigned long sizeChildren() const;
int getChild(int index) const;
double getValue() const;
int getAction() const;
private:
int id;
State m_state;
int m_nEvaluation;
double m_sumRewards;
int m_parentNode;
std::vector<int> m_children;
std::vector<int> m_actions;
int m_player;
int m_action;
};
class Tree{
public:
Tree();
void launchSearch(Board boardInit, int budget);
int bestAction() const;
int treePolicy();
int expand(Node* node);
void backUp(double winner, int node);
int getBestChild(int node);
private:
int m_playerIA;
int m_iteration;
int m_budget;
std::vector<Node> m_nodes;
};
#endif