-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
93 lines (72 loc) · 2.23 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
Bayesian Thomspon Distribution vs UCB MAB Solution
Description: Main Function
*/
// Includes
#include "master.hpp"
// Main Function
int main(int argc, char* argv[])
{
bool b_NOARGS = argc <= 1;
bool b_DEBUG = argc > 2 && !std::strcmp(argv[2], "-DEBUG");
if(b_DEBUG)
{
std::cout << "**** DEBUG MODE ACTIVE ****" << std::endl;
}
//guard statement against no arguments provided at execution
if(!b_NOARGS)
{
//guarge against negative #rounds
if(std::stol(argv[1]) <= 0)
{
std::cout << "You entered a number of rounds < or = 0." << std::endl;
std::cout << "When executing please oberve documentation." << std::endl;
exit(1);
}
unsigned long num_rounds = std::stol(argv[1]);
// Create a data structure to track wins, losses and ties for each algo.
tracker record;
//DEBUG TEST
// currently splits 50/50 to test data structure and output
if(b_DEBUG)
{
DEBUG(num_rounds, record);
}else
{
//COMPETITIVE LOGIC
int last_result;
bays_arm rock, paper, scissors;
ucb_arm rock2, paper2, sciss2;
RPS p1_choice = NOCHOICE, p2_choice = NOCHOICE;
for(unsigned long i = 0; i < num_rounds; i++)
{
// last_result is:
// 1 for Main Strat Win
// -1 for BBEC / Runner Up Win
// 0 for TIE
std::cout << "Game " << i+1 << " ";
p1_choice = GroupStrategy(rock, paper, scissors, p1_choice,
last_result, b_DEBUG);
p2_choice = BigBadEvilCode(rock2, paper2, sciss2, b_DEBUG,
p2_choice, last_result, i+1);
/*
p2_choice = GroupStrategy(rock2, paper2, sciss2, p2_choice,
last_result*-1, b_DEBUG);
*/
int result = playRPS(p1_choice, p2_choice);
last_result = result;
record.record_game(result);
}
}
// Display the statistical results of the matches
record.print_results("Bayesian Thomspon Sampler (BTS)", "B.B.E.C");
}
else
{
//output error from NOARGS
std::cout << "No arguments provided. Please enter the number of trials "
<< " to run as an argument." << std::endl;
exit(1);
}
return 0;
}