-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
77 lines (64 loc) · 2.04 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
#include "main.h"
int main() {
cout << "Enter number of threads to execute with: ";
int threads;
cin >> threads;
vector<Simulator> sims(threads);
ConsoleClear();
cout << "Uptime: ";
system_clock::time_point startTime = system_clock::now();
UpdatingLabel labelUptime( [&startTime]() { return GetUptime(startTime); } );
cout << endl;
cout << "Total Simulations: ";
UpdatingLabel labelSimulationCount( [&sims]() -> string {
long long int count = 0;
for(size_t i = 0; i < sims.size(); ++i)
count += sims[i].NumSimulations;
ostringstream ss;
ss << count;
return ss.str();
});
cout << endl;
cout << "Average Score: ";
UpdatingLabel labelAverageScore( [&sims]() -> string {
long long int count = 0;
long long int score = 0;
for(size_t i = 0; i < sims.size(); ++i) {
count += sims[i].NumSimulations;
score += sims[i].TotalScore;
}
ostringstream ss;
ss << setprecision(50) << double(score) / count;
return ss.str();
});
cout << endl;
cout << "Press enter to terminate: ";
Updater labelUpdater( [&labelUptime, &labelSimulationCount, &labelAverageScore]() -> void {
labelUptime.Update();
labelSimulationCount.Update();
labelAverageScore.Update();
}, 50);
cin.ignore();
cin.get();
labelUpdater.StopAndWait();
for(size_t i = 0; i < sims.size(); ++i)
sims[i].StopAndWait();
string finalUptime = GetUptime(startTime);
ConsoleClear();
cout << "Simulations terminated successfully" << endl;
cout << "Total time taken: " << finalUptime << endl;
long long int finalSimsCount = 0;
long long int finalScore = 0;
for(size_t i = 0; i < sims.size(); ++i) {
finalSimsCount += sims[i].NumSimulations;
finalScore += sims[i].TotalScore;
}
cout << "Total number of simulations ran: " << finalSimsCount << endl;
cout << "Total score of all simulations: " << finalScore << endl;
cout << "Maximum score achieved: " << Simulator::MaxScore << endl;
cout << "Average score across all simulations: "
<< setprecision(50) << double(finalScore) / finalSimsCount << endl;
cout << "Press enter to exit: ";
cin.get();
return 0;
}