-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShowdownNode.cpp
42 lines (35 loc) · 1.4 KB
/
ShowdownNode.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
//
// Created by Xuefeng Huang on 2020/1/30.
//
#include "include/nodes/ShowdownNode.h"
#include <utility>
ShowdownNode::ShowdownNode(vector<double> tie_payoffs, vector<vector<double>> player_payoffs,
GameTreeNode::GameRound round, double pot, shared_ptr<GameTreeNode>parent):
GameTreeNode(round,pot,std::move(parent)) {
this->tie_payoffs = std::move(tie_payoffs);
this->player_payoffs = std::move(player_payoffs);
}
double ShowdownNode::get_payoffs(ShowdownNode::ShowDownResult result, int winner,int player) {
if(result == ShowDownResult::NOTTIE){
if(winner == -1) throw runtime_error("winner == -1 in tie");
return player_payoffs[winner][player];
}else{
// if the showdown is a tie
if(winner != -1) throw runtime_error("winner != -1 in not tie");
return this->tie_payoffs[player];
}
}
vector<double> ShowdownNode::get_payoffs(ShowdownNode::ShowDownResult result, int winner) {
if(result == ShowDownResult::NOTTIE){
if(winner == -1) throw runtime_error("winner == -1 in tie");
vector<double> retval = player_payoffs[winner];
return retval;
}else{
// if the showdown is a tie
if(winner != -1) throw runtime_error("winner != -1 in not tie");
return this->tie_payoffs;
}
}
GameTreeNode::GameTreeNodeType ShowdownNode::getType() {
return SHOWDOWN;
}