diff --git a/source/Player.hpp b/source/Player.hpp index e26d6bd..448a0d2 100644 --- a/source/Player.hpp +++ b/source/Player.hpp @@ -8,10 +8,23 @@ typedef enum { class Player { public: - long points = 0; + /* Gathered points during the game are stored internally + */ + long points = 0; + /* This is for logging the game + */ const char * name; + /* Called before facing a new opponent + */ virtual void new_game() = 0; + /* Called during a match; + * the return value is your response + */ virtual reaction_t play() = 0; + /* Called after the match; + * the argument signals what your opponent played; + * you may use/store this information as you wish + */ virtual void push_result(reaction_t opponents_last_reaction) = 0; }; diff --git a/source/main.cpp b/source/main.cpp index 9190a0f..a606ce5 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -9,7 +9,6 @@ using namespace std; vector players; - const int ROUND_COUNT = 200; inline @@ -39,28 +38,39 @@ void play_round(Player * const p1, Player * const p2) { Player * const pw = (p1_play == CONFLICT) ? p1 : p2; pw->points += 5; } + p1->push_result(p2_play); p2->push_result(p1_play); } signed main() { + /* we seed, rand for you, in case you wish to use it, + * please do not re seed it + */ srand(time(NULL)); + // YYY: Every player is added here players.push_back(new RandomPlayer()); players.push_back(new RandomPlayer()); players.push_back(new RandomPlayer()); + // -- + /* Every players playes with every player exactly once + */ for (int i = 0; i < players.size() - 1; i++) { for (int h = i + 1; h < players.size(); h++) { printf("%s VS %s\n", players[i]->name, players[h]->name); players[i]->new_game(); players[h]->new_game(); + /* Each game takes some number of turns + */ for (int c = 0; c < ROUND_COUNT; c++) { play_round(players[i], players[h]); } } } + // Results for (const auto &p : players) { printf("%s: %ld\n", p->name, p->points); }