#include using namespace std; class NapoleonPlayer : public Player { private: int baseOfOp; public: virtual void doAllocation(int newArmies) { int myID = theGame->getPlayerID(this); Country countries[MAXCOUNTRY]; int countryCount; countryCount = theGame->getCountries(countries); while (true) { // choose a country randomly int randInd = rand()%countryCount; baseOfOp = countries[randInd].getID(); // until we find one that belongs to someone else if (countries[randInd].getPlayer() == myID) { // put all our armies there theGame->doAllocation(baseOfOp,newArmies); break; } } // if we want to print out all our country names ... //for (int c = 0; c < countryCount; c++) { // if (countries[c].getPlayer() == myID) { // cout << names[countries[c].getID()] // << endl; // } //} } virtual bool doAttack() { int myID = theGame->getPlayerID(this); Country countries[MAXCOUNTRY]; int countryCount; countryCount = theGame->getCountries(countries); // find a country that is next to // the one where we put all our armies // (may turn out to be one of ours!) for (int i = 0; i < countryCount; i++) { if (theGame->areAdjacent( baseOfOp, countries[i].getID())) { theGame->attack(baseOfOp,countries[i].getID()); break; // one attack is enough for now } } return false; } // return value indicates // whether player wishes to attack again };