gtheler 5 лет назад
Родитель
Сommit
75816ec095
2 измененных файлов: 22 добавлений и 12 удалений
  1. +8
    -6
      src/base.h
  2. +14
    -6
      src/report.cpp

+ 8
- 6
src/base.h Просмотреть файл

@@ -227,6 +227,13 @@ class Player {
Hand dealerHand;
};

struct reportItem {
reportItem(std::string k, std::string f, double v) : key(k), format(f), value(v) {};
std::string key;
std::string format;
double value;
};

class Dealer {
public:
Dealer() = default;
@@ -320,12 +327,7 @@ class Dealer {

private:
bool done = false;
std::unordered_map<std::string, std::string> results;

void insert(std::string key, std::string value) {
results.insert(std::pair<std::string, std::string>(key, value));
}
std::list<reportItem> report;
};


+ 14
- 6
src/report.cpp Просмотреть файл

@@ -10,11 +10,17 @@ void Dealer::reportPrepare(void) {
double ev = (double) playerStats.result / (double) n_hand;
double error = error_standard_deviations * sqrt (playerStats.variance / (double) n_hand);
insert("result", std::to_string(ev));
insert("variance", std::to_string(playerStats.variance));
insert("deviation", std::to_string(sqrt(playerStats.variance)));
insert("error", std::to_string(error));
report.push_back(reportItem("bankroll", "%g", playerStats.bankroll));
report.push_back(reportItem("result", "%g", playerStats.result));
report.push_back(reportItem("ev", "%g", ev));
report.push_back(reportItem("hands", "%g", n_hand));
report.push_back(reportItem("variance", "%g", playerStats.variance));
report.push_back(reportItem("deviation", "%g", sqrt(playerStats.variance)));
report.push_back(reportItem("error", "%g", error));
report.push_back(reportItem("played_hands", "%g", n_hands));
report.push_back(reportItem("total_money_waged", "%g", playerStats.totalMoneyWaged));
return;
}

@@ -32,8 +38,10 @@ int Dealer::writeReportYAML(void) {

// TODO: choose if comments with explanations are to be added
std::cerr << "---" << std::endl;
for (auto it = results.begin(); it != results.end(); ++it) {
std::cerr << it->first << ": " << it->second << std::endl;
for (auto item : report) {
std::cerr << item.key << ": ";
fprintf(stderr, item.format.c_str(), item.value);
std::cerr << std::endl;
}
// std::cerr << "rules:" << std::endl;

Загрузка…
Отмена
Сохранить