Your classes describe the state machine without if or switch, and that's fine. You need to add virtual destructors though! Now you only need to add one state (the starting state) to each player and some events that trigger a change of state:
class player {
std::unique_ptr<state> current_state;
public:
player(std::unique_ptr<state> starting_state) : current_state(starting_state) {}
void setState(std::unique_ptr<state> other_state) { current_state = other_state; }
void onSwitch() { }
void onFlee() { current_state = new flee; }
void onSeek() { current_state = new seek; }
};
Then you need to insert code that describes the interaction between players. Maybe a class
arena
that contains the players and controls when and how they (inter)act:
class arena {
player player1;
player player2;
int player1_score;
int player2_score;
public:
arena() : player1(new seek()), player2(new flee()) {}
void startGame (); void nextTurn(); int currentLeader(); };