-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionNode.cpp
71 lines (59 loc) · 2.25 KB
/
ActionNode.cpp
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
//
// Created by Xuefeng Huang on 2020/1/30.
//
#include "include/nodes/ActionNode.h"
#include <utility>
#include <include/trainable/DiscountedCfrTrainable.h>
#include <include/trainable/DiscountedCfrTrainableHF.h>
#include <include/trainable/DiscountedCfrTrainableSF.h>
ActionNode::~ActionNode(){
//cout << "ActionNode destroyed" << endl;
}
ActionNode::ActionNode(vector<GameActions> actions, vector<shared_ptr<GameTreeNode>> childrens, int player,
GameTreeNode::GameRound round, double pot, shared_ptr<GameTreeNode> parent) :GameTreeNode(round,pot,std::move(parent)){
this->actions = std::move(actions);
this->player = player;
this->childrens = std::move(childrens);
//cout << "ActionNode created" << endl;
}
vector<GameActions>& ActionNode::getActions() {
return this->actions;
}
vector<shared_ptr<GameTreeNode>>& ActionNode::getChildrens() {
return this->childrens;
}
int ActionNode::getPlayer() {
return this->player;
}
GameTreeNode::GameTreeNodeType ActionNode::getType() {
return ACTION;
}
shared_ptr<Trainable> ActionNode::getTrainable(int i,bool create_on_site, int use_halffloats) {
if(i > this->trainables.size()){
throw runtime_error(tfm::format("size unacceptable %s > %s ",i,this->trainables.size()));
}
if(this->trainables[i] == nullptr && create_on_site){
switch ((this->getRound() == GameTreeNode::RIVER) ? use_halffloats : 0 ){
case 0:
this->trainables[i] = make_shared<DiscountedCfrTrainable>(player_privates,*this);
break;
case 1:
this->trainables[i] = make_shared<DiscountedCfrTrainableSF>(player_privates,*this);
break;
case 2:
this->trainables[i] = make_shared<DiscountedCfrTrainableHF>(player_privates,*this);
break;
}
}
return this->trainables[i];
}
void ActionNode::setTrainable(vector<shared_ptr<Trainable>> trainables,vector<PrivateCards>* player_privates) {
this->trainables = trainables;
this->player_privates = player_privates;
}
void ActionNode::setActions(const vector<GameActions> &actions) {
ActionNode::actions = actions;
}
void ActionNode::setChildrens(const vector<shared_ptr<GameTreeNode>> &childrens) {
ActionNode::childrens = childrens;
}