-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMCTSNode.h
More file actions
57 lines (36 loc) · 1.22 KB
/
Copy pathMCTSNode.h
File metadata and controls
57 lines (36 loc) · 1.22 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
//
// Created by DFZ on 2018/4/18.
//
#ifndef REVERSI_MCTSNODE_H
#define REVERSI_MCTSNODE_H
#include <vector>
#include <memory>
#include <cmath>
#include <random>
#include "Reversi.h"
class MCTSNode {
private:
int wonTimes = 0;
int visitTimes = 0;
bool win = false;
MCTSNode *father;
public:
Reversi boardState;
int color;
std::vector<std::shared_ptr<MCTSNode>> children;
MCTSNode(MCTSNode *father, const Reversi &boardState, int color);
bool isAllExpanded();
std::shared_ptr<MCTSNode> bestChild();
std::shared_ptr<MCTSNode> randomUnexpandedChild();
void genChildren();
friend std::shared_ptr<MCTSNode> selection(std::shared_ptr<MCTSNode> node);
friend std::shared_ptr<MCTSNode> expansion(std::shared_ptr<MCTSNode> node);
friend std::shared_ptr<MCTSNode> simulation(std::shared_ptr<MCTSNode> node);
friend void backpropagation(MCTSNode *node, int color);
std::shared_ptr<MCTSNode> completeGameRandomly();
static const int C = static_cast<const int>(sqrt(2));
std::shared_ptr<MCTSNode> decideNext();
std::shared_ptr<MCTSNode> selectNext(int row, int column);
std::shared_ptr<MCTSNode> genChild(int row, int column);
};
#endif //REVERSI_MCTSNODE_H