Browse Source

report

master
gtheler 5 years ago
parent
commit
75816ec095
2 changed files with 22 additions and 12 deletions
  1. +8
    -6
      src/base.h
  2. +14
    -6
      src/report.cpp

+ 8
- 6
src/base.h View File

Hand dealerHand; 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 { class Dealer {
public: public:
Dealer() = default; Dealer() = default;


private: private:
bool done = false; 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 View File

double ev = (double) playerStats.result / (double) n_hand; double ev = (double) playerStats.result / (double) n_hand;
double error = error_standard_deviations * sqrt (playerStats.variance / (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; return;
} }




// TODO: choose if comments with explanations are to be added // TODO: choose if comments with explanations are to be added
std::cerr << "---" << std::endl; 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; // std::cerr << "rules:" << std::endl;

Loading…
Cancel
Save