Few people know that I wrote a very sophisticated simulator to determine the output of the Congressional Select Committe on Benghazi. It’s always satisfying to see simulation results match the real world.
Here’s me running the program:
1 2 3 |
cavalier $> g++ -Wall -std=c++11 benghazi_sim.cpp cavalier $> ./a.out Welcome, Madam President! |
Here’s the source code, in case you want to expand on the idea.
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 78 79 80 |
#include <vector> #include <algorithm> #include <iostream> extern const std::vector<std::string> congress_names; const int PR_BIG_WIN = 2; enum opinions_t { OP_SEEMS_EVIL, OP_SEEMS_NICE, OP_DONT_CARE, _OP_NA, }; enum evil_level_t { EV_NOT_REALLY, EV_A_BIT, EV_YEAH, EV_UH_OH, EV_VERY, EV_CTHULU, _EV_NA, }; class politician_c { public: politician_c(); bool initFrom(std::string fn); evil_level_t fromPerspective(opinions_t which) const; int badAssitude() const; bool isRepub() const; bool isOnBenghaziCommittee() const; private: }; void loadCongress(std::vector<politician_c *> &c, const std::vector<std::string> names) { for (std::string name: names) { std::string fn = name; fn.append(".dat"); politician_c *member = new politician_c(); member->initFrom(fn); c.push_back(member); }; } int main(int argc, char *argv[]) { politician_c hillary; hillary.initFrom("hillary.dat"); std::vector<politician_c *> congress; loadCongress(congress,congress_names); int hillaryMustDie = 0; for (politician_c *p : congress) { if (p->isRepub() && (p->fromPerspective(OP_SEEMS_EVIL) >= EV_CTHULU)) { hillaryMustDie++; } } if (hillaryMustDie) { int PR_winCount = 0; for (politician_c *p : congress) { if (p->isRepub() && p->isOnBenghaziCommittee()) { if (p->badAssitude() > hillary.badAssitude()) PR_winCount++; } } std::string os; if (PR_winCount >= PR_BIG_WIN) { os = "Uh oh, Hillary is in trouble."; } else if (PR_winCount) { os = "Well, that was at least interesting."; } else { os = "Welcome, Madam President!"; } std::cout << os << std::endl; } }; |
Yes, the code above compiles. But no, I never really ran the program because it does not link. I never created an implementation for politician_c. Was just fooling around.