-
Notifications
You must be signed in to change notification settings - Fork 0
/
Evaluator.cpp
51 lines (40 loc) · 1.07 KB
/
Evaluator.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
#include <iostream>
#include "Evaluator.h"
#include "Match.h"
Evaluator::Evaluator(Game* game, Match* match)
: game(game) {
interactions = match->match_results.rounds_results;
}
std::vector<PayoffPair> Evaluator::compute_scores()
{
for (DecisionPair dp : interactions)
{
scores.push_back(game->score(dp));
}
return scores;
}
PayoffPair Evaluator::compute_final_score()
{
if (scores.size() == 0)
{
compute_scores();
}
Payoff final_score_player1 = 0;
Payoff final_score_player2 = 0;
for (PayoffPair score : scores)
{
final_score_player1 += score.first;
final_score_player2 += score.second;
}
final_score = PayoffPair(final_score_player1, final_score_player2);
return final_score;
};
PayoffPair Evaluator::compute_final_score_per_turn()
{
if (!final_score.first && !final_score.second)
{
compute_final_score();
}
if (scores.size() == 0) return PayoffPair(0,0);
return PayoffPair((double)final_score.first / scores.size(), (double)final_score.second / scores.size());
}