-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
69 lines (53 loc) · 1.47 KB
/
test.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
#include <chrono>
#include <fstream>
#include <iostream>
#include <valarray>
#include <vector>
#include "predictor.hpp"
int main(int argc, char* argv[])
{
if (argc != 2) {
std::cout << "Error argument" << std::endl;
return 1;
}
std::ifstream fin(argv[1]);
if (!fin) {
std::cout << "Input file does not exist" << std::endl;
return 0;
}
pred::Predictor predictor;
predictor.initialize(WIN_RDY_FILE_PATH);
int m;
std::vector<int> wall(K, 4);
std::vector<int> river(K, 0);
fin >> m;
for (int i = 0; i < K; ++i) {
fin.ignore(3, ' ');
fin >> wall[i] >> river[i];
}
auto start = std::chrono::system_clock::now();
std::vector<pred::Value> values;
std::valarray<double> props;
try {
values = predictor(wall, river, m);
props = values[0].props();
}
catch (std::runtime_error& e) {
std::cout << e.what() << std::endl;
return 0;
}
auto end = std::chrono::system_clock::now();
std::cout << "Total\t" << values[0].all << std::endl;
std::cout << "Wait\tNormalHand\tSevenPairs\tThirteenOrphans\tProportion" << std::endl;
for (int i = 0; i < K; ++i) {
std::cout << i << "\t"
<< values[1].states[i] << "\t"
<< values[2].states[i] << "\t"
<< values[3].states[i] << "\t"
<< props[i] << std::endl;
}
std::cout << "Time (msec.)\t"
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
<< std::endl;
return 0;
}