#include "Player.hpp"

#include <stdlib.h>

class Anon : public Player {
  public:
    Anon() {
        name = "Anon";
    }

    reaction_t past[2];

    void new_game() override {
        past[0] = COOPERATE;
        past[1] = COOPERATE;
    }
    void push_result(reaction_t opponents_last_reaction) override {
        past[0] = past[1];
        past[1] = opponents_last_reaction;
    }

    reaction_t play() override {
        if (rand() % 20 == 0) {
            return CONFLICT;
        }

        return (past[0] == CONFLICT && past[1] == CONFLICT) ? CONFLICT : COOPERATE;
    }
};
