-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.hpp
More file actions
38 lines (36 loc) · 1.27 KB
/
Node.hpp
File metadata and controls
38 lines (36 loc) · 1.27 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
#pragma once
#include <bits/stdc++.h>
#include "Game.hpp"
#include "Move.hpp"
class Node
{
private:
std::vector<double> score;
int simulations;
int lastExpanded;
double trueGameResult;
bool terminal;
std::shared_ptr<Game> game;
std::weak_ptr<Node> parent; // This can't be a shared pointer
std::vector<std::shared_ptr<Move>> possibleMoves;
std::unordered_map<int, std::shared_ptr<Node>> children;
std::vector<double> moveScores; // This should be in a new class that inherits from this one
public:
Node(std::vector<std::shared_ptr<Move>> moves, std::shared_ptr<Game> game, std::shared_ptr<Node> ancestor = nullptr);
int getLastExpanded();
void setLastExpanded(int last);
bool getTerminal();
void setTerminal(bool terminal);
std::vector<std::shared_ptr<Move>> getPossibleMoves();
int getSimulations();
void setSimulations(int simulations);
double getScore(int player);
void setScore(int player, double score);
std::unordered_map<int, std::shared_ptr<Node>> &getChildren();
std::shared_ptr<Game> getGame();
std::shared_ptr<Node> getParent();
const std::vector<double> &getMoveScores();
void setMoveScores(const std::vector<double> &moveScores);
double getTrueGameResult();
void setTrueGameResult(double trueGameResult);
};