-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
93 lines (76 loc) · 1.62 KB
/
Node.cpp
File metadata and controls
93 lines (76 loc) · 1.62 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "Node.hpp"
Node::Node(std::vector<std::shared_ptr<Move>> moves, std::shared_ptr<Game> game, std::shared_ptr<Node> ancestor)
{
std::random_shuffle(moves.begin(), moves.end());
this->game = game;
this->possibleMoves = moves;
this->score = {0.0, 0.0};
this->parent = ancestor;
this->simulations = 0;
this->lastExpanded = -1;
this->terminal = game->gameStatus(moves) != -1;
}
int Node::getLastExpanded()
{
return this->lastExpanded;
}
void Node::setLastExpanded(int last)
{
this->lastExpanded = last;
}
bool Node::getTerminal()
{
return this->terminal;
}
void Node::setTerminal(bool terminal)
{
this->terminal = terminal;
}
std::vector<std::shared_ptr<Move>> Node::getPossibleMoves()
{
return this->possibleMoves;
}
int Node::getSimulations()
{
return this->simulations;
}
void Node::setSimulations(int simulations)
{
this->simulations = simulations;
}
double Node::getScore(int player)
{
return this->score[player];
}
void Node::setScore(int player, double score)
{
this->score[player] = score;
}
std::unordered_map<int, std::shared_ptr<Node>> &Node::getChildren()
{
return this->children;
}
std::shared_ptr<Game> Node::getGame()
{
return this->game;
}
std::shared_ptr<Node> Node::getParent()
{
return this->parent.lock();
}
const std::vector<double> &Node::getMoveScores()
{
return this->moveScores;
}
void Node::setMoveScores(const std::vector<double> &moveScores)
{
this->moveScores = moveScores;
}
double Node::getTrueGameResult()
{
return this->trueGameResult;
}
void Node::setTrueGameResult(double trueGameResult)
{
this->trueGameResult = trueGameResult;
}