classGameAI { public: std::vector<Structure*> builtStructures; voidturn(){ collectResources(); buildStructures(); buildUnits(); attack(); } voidcollectResources(){ for (Structure* s: builtStructures) { s->collect(); } } virtualbuildStructures()= 0; virtualbuildUnits()= 0; voidattack(){ Enemy* e = closestEnemy(); Map* m = getMap(); if (e == nullptr) sendScouts(m->center); elsesendWarriors(e->position); } virtualsendScouts(Coords pos)= 0; virtualsendWarriors(Coords pos)= 0; };
classOrcsAI: public GameAI { voidbuildStructures()override{ if (resourceAvailable()) { // build things } } voidbuildUnits()override{ // build some units } // also implement sendScouts and sendWarriors };