#include using namespace std; class Player { public: Player(const string &n){ name=n; }; virtual ~Player(); virtual const string & getType() const=0; virtual Move play(const State &s) =0; friend ostream & operator << (ostream &out, const Player &player); protected:string name; }; class GreedyPlayer :public Player { public: GreedyPlayer(const string &n): Player(n) { playertype="Greedy"; } const string & getType() const override { return playertype; } Move play(const State &s) override { int sHeap=0; int sCoins=0; for(int i=0; isCoins) { sHeap=i; sCoins=s.getCoins(i); } Move Greedyplay(sHeap, sCoins, 0, 0); return Greedyplay; } private: string playertype; }; class SpartanPlayer: public Player { public: SpartanPlayer(const string &n): Player(n) { playertype="Spartan"; } const string & getType() const override { return playertype; } Move play(const State &s) override { int sHeap=0; int sCoins=0; for(int i=0; isCoins) { sHeap=i; sCoins=s.getCoins(i); } Move Spartanplay(sHeap, 1, 0, 0); return Spartanplay; } private: string playertype; }; class SneakyPlayer:public Player { public: SneakyPlayer(const string &n): Player(n) { playertype="Sneaky"; } const string & getType() const override { return playertype; } Move play(const State &s) override { int sHeap=0; int sCoins; if(s.getCoins(0)>0) sCoins=s.getCoins(0); else sCoins=100; for(int i=1; i0) { sHeap=i; sCoins=s.getCoins(i); } } Move Sneakyplay(sHeap, sCoins, 0, 0); return Sneakyplay; } private: string playertype; }; class RighteousPlayer: public Player { public: RighteousPlayer(const string &n): Player(n){ playertype="Righteous"; } const string & getType() const override { return playertype; } Move play(const State &s) override { int sHeap=0; int tHeap=0; int maxCoins=0; int minCoins=s.getCoins(0); for(int i=0; imaxCoins) { sHeap=i; maxCoins=s.getCoins(i); } if(s.getCoins(i)