-
Notifications
You must be signed in to change notification settings - Fork 2
/
statistics.h
executable file
·59 lines (52 loc) · 1.19 KB
/
statistics.h
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
#include "GameState.h"
#include "Game.h"
#include <vector>
#include <string>
#ifndef STATISTICS_CPP
#define STATISTICS_CPP
namespace hearts {
enum tStatType {
kPlayerStat = 1,
kAlgorithmStat = 2,
kCheckpointStat = 3
};
class playData {
public:
std::string algorithms;
tStatType type;
int player;
int wins;
int plays;
int score;
int rank;
std::vector<int> scores;
std::vector<int> ranks;
void save(FILE *f)
{
fprintf(f, "%s %d %d %d %d %d %d\n", algorithms.c_str(), (int)type, player, wins, plays, score, rank);
fprintf(f, "%d %d\n", (int)scores.size(), (int)ranks.size());
for (unsigned int x = 0; x < scores.size(); x++)
fprintf(f, "%d ", scores[x]);
fprintf(f, "\n");
for (unsigned int x = 0; x < ranks.size(); x++)
fprintf(f, "%d ", ranks[x]);
fprintf(f, "\n");
}
};
class statistics {
public:
statistics() { checkpointed = false; }
~statistics() { save(); }
void collect(Game *g, GameState *gs, bool show=true);
void checkpoint();
void save(const char *file = "results.txt");
void reset() { data.resize(0); }
private:
void sort();
double getStdDev(std::vector<int> &vec);
void showSignificance(FILE *f);
std::vector<playData> data;
bool checkpointed;
};
}
#endif