-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNode.cpp
More file actions
66 lines (59 loc) · 1.72 KB
/
Copy pathNode.cpp
File metadata and controls
66 lines (59 loc) · 1.72 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
#include "Node.h"
#include <Windows.h>
#include <iostream>
#include <sstream>
#include <string>
//Node::Node(const Node & node)
//{
// node_type = node.node_type;
// street = node.street;
// board = node.board;
// board_string = node.board_string;
// current_player = node.current_player;
// bets = Eigen::Array2(node.bets);
// pot = node.pot;
// terminal = terminal;
//}
Node::Node() : street(1), current_player(chance), bets(2), terminal(false), depth(-1), type(uninitialized), board_string(""), pot(0),
ranges(players_count, card_count) //ToDo: Performance Warning: do we really need default constructor to save the performance?
{
cf_values = ArrayXX::Zero(players_count, card_count); // We need to do this because of empty fold. We are still comping it values and it should be zeros.
}
Node::~Node()
{
for (size_t i = 0; i < children.size(); i++)
{
Node* cur_node = children[i];
if (cur_node != nullptr)
{
delete(cur_node);
}
children.clear();
}
}
string GetNodeTypeString(const node_types value) {
static map<node_types, string> strings;
if (strings.size() == 0) {
#define INSERT_ELEMENT(p) strings[p] = #p
INSERT_ELEMENT(uninitialized);
INSERT_ELEMENT(terminal_fold);
INSERT_ELEMENT(terminal_call);
INSERT_ELEMENT(check);
INSERT_ELEMENT(chance_node);
INSERT_ELEMENT(inner_node);
#undef INSERT_ELEMENT
}
return strings[value];
}
void Node::ToString()
{
wostringstream ss;
ss << "Type: " << GetNodeTypeString(type).c_str();
ss << ". Player: " << current_player;
ss << ". Street: " << street;
ss << ". Depth: " << depth;
ss << ". board_string: " << board_string.c_str();
ss << ". IsTerminal: " << terminal << L"\n";
ss << " Bets: [" << bets(0) << " , " << bets(1) << "] ";
OutputDebugString(ss.str().c_str());
}