CGeniusAI.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. #include "CGeniusAI.h"
  2. #include <iostream>
  3. #include "../../hch/CBuildingHandler.h"
  4. #include "../../lib/VCMI_Lib.h"
  5. using namespace std;
  6. using namespace GeniusAI;
  7. #if defined (_MSC_VER) && (_MSC_VER >= 1020) || (__MINGW32__)
  8. #include <windows.h>
  9. #endif
  10. void DbgBox(const char *msg, bool messageBox)
  11. {
  12. #if defined PRINT_DEBUG
  13. #if defined _DEBUG
  14. //#if 0
  15. # if defined (_MSC_VER) && (_MSC_VER >= 1020)
  16. if (messageBox)
  17. {
  18. MessageBoxA(NULL, msg, "Debug message", MB_OK | MB_ICONASTERISK);
  19. }
  20. # endif
  21. std::cout << msg << std::endl;
  22. #endif
  23. #endif
  24. }
  25. CGeniusAI::CGeniusAI()
  26. : m_generalAI(), turn(0), m_state(NO_BATTLE), firstTurn(true)
  27. {
  28. }
  29. CGeniusAI::~CGeniusAI()
  30. {
  31. }
  32. void CGeniusAI::init(ICallback *CB)
  33. {
  34. m_cb = CB;
  35. m_generalAI.init(CB);
  36. human = false;
  37. playerID = m_cb->getMyColor();
  38. serialID = m_cb->getMySerial();
  39. std::string info = std::string("GeniusAI initialized for player ") + boost::lexical_cast<std::string>(playerID);
  40. m_battleLogic = NULL;
  41. DbgBox(info.c_str());
  42. }
  43. unsigned long randomFromInt(unsigned long in)
  44. {
  45. return (in*214013+2531011);
  46. }
  47. void CGeniusAI::reportResources()
  48. {
  49. std::cout << "AI Player " <<m_cb->getMySerial()<< " with " << m_cb->howManyHeroes(true) << " heroes. " << std::endl;
  50. std::cout << m_cb->getResourceAmount(0) << " wood. ";
  51. std::cout << m_cb->getResourceAmount(1) << " mercury. ";
  52. std::cout << m_cb->getResourceAmount(2) << " ore. ";
  53. std::cout << m_cb->getResourceAmount(3) << " sulfer. ";
  54. std::cout << m_cb->getResourceAmount(4) << " cristal. ";
  55. std::cout << m_cb->getResourceAmount(5) << " gems. ";
  56. std::cout << m_cb->getResourceAmount(6) << " gold.";
  57. std::cout << std::endl;
  58. }
  59. void CGeniusAI::addHeroObjectives(CGeniusAI::HypotheticalGameState::HeroModel &h, CGeniusAI::HypotheticalGameState &hgs)
  60. {
  61. int3 hpos, destination;
  62. CPath path;
  63. hpos = h.pos;
  64. int movement = h.remainingMovement;
  65. int3 interestingPos;
  66. int maxInteresting=0;
  67. for(std::set<AIObjectContainer>::const_iterator i = hgs.knownVisitableObjects.begin(); i != hgs.knownVisitableObjects.end();i++)
  68. {
  69. // if(i->o->ID==54||i->o->ID==34) //creatures, another hero
  70. // continue;
  71. if(i->o->ID==53&&i->o->getOwner()==m_cb->getMyColor())//don't visit a mine if you own, there's almost no point(maybe to leave guards or because the hero's trapped).
  72. continue;
  73. destination = i->o->getSightCenter();
  74. if(hpos.z==destination.z) //don't try to take a path from the underworld to the top or vice versa
  75. {
  76. if(m_cb->getPath(hpos,destination,h.h,path))
  77. {
  78. path.convert(0);
  79. if(path.nodes[0].dist<movement)
  80. {
  81. AIObjective::Type tp = AIObjective::visit;
  82. HeroObjective ho(tp,i->o,&h);
  83. std::set<HeroObjective>::iterator found = currentHeroObjectives.find(ho);
  84. if(found==currentHeroObjectives.end())
  85. currentHeroObjectives.insert(ho);
  86. else
  87. found->whoCanAchieve.push_back(&h);
  88. }
  89. // find the most interesting object that is eventually reachable, and set a similar (out of the way) position to the ultimate goal position
  90. int hi = rand(); //TODO: replace random numbers with some sort of ranking system
  91. if(hi>maxInteresting)
  92. {
  93. maxInteresting = hi;
  94. interestingPos = destination;
  95. }
  96. }
  97. }
  98. }
  99. //find close pos with the most neighboring empty squares
  100. if(h.remainingMovement>0&&m_cb->getPath(hpos,interestingPos,h.h,path))
  101. {
  102. int3 bestPos = interestingPos,currentPos,destPos;
  103. int howGood=0;
  104. for(int x = -2;x <= 2;x++)
  105. for(int y = -2;y <= 2;y++)
  106. {
  107. currentPos=interestingPos+int3(x,y,0);
  108. if(m_cb->getVisitableObjs(destPos).size()!=0) //there better not be anything there
  109. continue;
  110. if(!m_cb->getPath(hpos,destPos,h.h,path)) //it had better be reachable from the hero
  111. continue;
  112. int count = 0;
  113. for(int xx = -1;xx <= 1;xx++)
  114. for(int yy = -2;yy <= 1;yy++)
  115. {
  116. destPos = currentPos+int3(xx,yy,0);
  117. if(m_cb->getPath(currentPos,destPos,h.h,path))
  118. count++;
  119. }
  120. if(count > howGood)
  121. {
  122. howGood = count;
  123. bestPos = currentPos;
  124. }
  125. }
  126. h.interestingPos = bestPos;
  127. currentHeroObjectives.insert(HeroObjective(HeroObjective::finishTurn,h.h,&h));
  128. }
  129. }
  130. void CGeniusAI::HeroObjective::fulfill(CGeniusAI & cg,HypotheticalGameState & hgs)
  131. {
  132. HypotheticalGameState::HeroModel * h;
  133. int3 hpos, destination;
  134. CPath path;
  135. CPath path2;
  136. switch(type)
  137. {
  138. case finishTurn:
  139. h = whoCanAchieve.front();
  140. hpos = h->pos;
  141. destination = h->interestingPos;
  142. if(!cg.m_cb->getPath(hpos,destination,h->h,path)) {cout << "AI error: invalid destination" << endl; return;}
  143. // path.convert(0);
  144. destination = h->pos;
  145. for(int i = path.nodes.size()-2;i>=0;i--) //find closest coord that we can get to
  146. if(cg.m_cb->getPath(hpos,path.nodes[i].coord,h->h,path2)&&path2.nodes[0].dist<=h->remainingMovement)
  147. destination = path.nodes[i].coord;
  148. break;
  149. case visit:
  150. //std::cout << "trying to visit " << object->hoverName << std::endl;
  151. h = whoCanAchieve[rand()%whoCanAchieve.size()];//TODO:replace with best hero for the job
  152. hpos = h->pos;
  153. destination = object->getSightCenter();
  154. break;
  155. }
  156. if(type == visit||type == finishTurn)
  157. if(cg.m_cb->getPath(hpos,destination,h->h,path))
  158. {
  159. path.convert(0);
  160. if(cg.m_state.get() != NO_BATTLE)
  161. cg.m_state.waitUntil(NO_BATTLE);//wait for battle end
  162. //wait over, battle over too. hero might be killed. check.
  163. for(int i = path.nodes.size()-2;i>=0&&(cg.m_cb->getHeroSerial(h->h) >= 0);i--)
  164. {
  165. cg.m_cb->moveHero(h->h,path.nodes[i].coord);
  166. if(cg.m_state.get() != NO_BATTLE)
  167. cg.m_state.waitUntil(NO_BATTLE);//wait for battle end
  168. }
  169. h->remainingMovement-=path.nodes[0].dist;
  170. if(object->blockVisit)
  171. h->pos = path.nodes[1].coord;
  172. else
  173. h->pos=destination;
  174. std::set<AIObjectContainer>::iterator i = hgs.knownVisitableObjects.find(AIObjectContainer(object));
  175. if(i!=hgs.knownVisitableObjects.end())
  176. hgs.knownVisitableObjects.erase(i);
  177. }
  178. }
  179. void CGeniusAI::addTownObjectives(HypotheticalGameState::TownModel &t, HypotheticalGameState & hgs)
  180. {
  181. //recruitHero
  182. //buildBuilding
  183. //recruitCreatures
  184. //upgradeCreatures
  185. if(hgs.heroModels.size()<3&&hgs.resourceAmounts[6]>=2500) //recruitHero
  186. {
  187. bool heroAtTown = false;
  188. for(int i = 0; i < hgs.heroModels.size();i++)
  189. if(hgs.heroModels[i].pos==t.t->getSightCenter())
  190. heroAtTown = true;
  191. if(!heroAtTown && vstd::contains(t.t->builtBuildings, 5)) //no visiting hero and built tavern
  192. {
  193. for(int i =0; i < hgs.AvailableHeroesToBuy.size();i++)
  194. if(hgs.AvailableHeroesToBuy[i]!=NULL&&hgs.AvailableHeroesToBuy[i]->getArmyStrength()>4000)//only buy heros with units
  195. {//TODO: recruit heros of own race.
  196. TownObjective to(AIObjective::recruitHero,&t,0);
  197. currentTownObjectives.insert(to);
  198. }
  199. }
  200. }
  201. //buildBuilding
  202. if(!t.hasBuilt)
  203. {
  204. std::map<int, CBuilding *> thisTownsBuildings = VLC->buildh->buildings[t.t->subID];// m_cb->getCBuildingsByID(t.t);
  205. for(std::map<int, CBuilding *>::iterator i = thisTownsBuildings.begin(); i != thisTownsBuildings.end();i++)
  206. {
  207. if(m_cb->canBuildStructure(t.t,i->first)==7)
  208. {
  209. TownObjective to(AIObjective::buildBuilding,&t,i->first);
  210. currentTownObjectives.insert(to);
  211. //cout <<"can build " << i->first << " "<< i->second->Name() << endl;
  212. }
  213. }
  214. }
  215. //recruitCreatures
  216. for(int i = 0; i < t.creaturesToRecruit.size() ;i++)
  217. {
  218. if(t.creaturesToRecruit[i].first==0) continue;
  219. int ID = t.creaturesToRecruit[i].second.back();
  220. const CCreature *creature = &VLC->creh->creatures[ID];//m_cb->getCCreatureByID(ID);
  221. bool canAfford = true;
  222. for(int ii = 0;ii<creature->cost.size();ii++)
  223. if(creature->cost[ii]>hgs.resourceAmounts[ii])
  224. canAfford = false;
  225. if(!canAfford) continue;
  226. //cout << "town has " << t.t->creatures[i].first << " "<< creature->namePl << " (AI Strength " << creature->AIValue << ")." << endl;
  227. TownObjective to(AIObjective::recruitCreatures,&t,i);
  228. currentTownObjectives.insert(to);
  229. }
  230. //upgradeCreatures
  231. /* for(int i = 0; i < t.creaturesToRecruit.size() ;i++)
  232. {
  233. if(t.creaturesToRecruit[i].first==0) continue;
  234. int ID = t.creaturesToRecruit[i].second.back();
  235. const CCreature *creature = m_cb->getCCreatureByID(ID);
  236. bool canAfford = true;
  237. for(int ii = 0;ii<creature->cost.size();ii++)
  238. if(creature->cost[ii]>hgs.resourceAmounts[ii])
  239. canAfford = false;
  240. if(!canAfford) continue;
  241. //cout << "town has " << t.t->creatures[i].first << " "<< creature->namePl << " (AI Strength " << creature->AIValue << ")." << endl;
  242. TownObjective to(AIObjective::recruitCreatures,&t,i);
  243. currentTownObjectives.insert(to);
  244. }*/
  245. }
  246. void CGeniusAI::TownObjective::fulfill(CGeniusAI & cg,HypotheticalGameState &hgs)
  247. {
  248. CBuilding * b;
  249. const CCreature *creature;
  250. HypotheticalGameState::HeroModel hm;
  251. switch(type)
  252. {
  253. case recruitHero:
  254. cg.m_cb->recruitHero(whichTown->t,hgs.AvailableHeroesToBuy[which]);
  255. hm = HypotheticalGameState::HeroModel(hgs.AvailableHeroesToBuy[which]);
  256. hm.pos = whichTown->t->getSightCenter();
  257. hm.remainingMovement = hm.h->maxMovePoints(true);
  258. hgs.heroModels.push_back(hm);
  259. hgs.resourceAmounts[6]-=2500;
  260. break;
  261. case buildBuilding:
  262. b = VLC->buildh->buildings[whichTown->t->subID][which];//cg.m_cb->getCBuildingsByID(whichTown->t)[which];
  263. if(cg.m_cb->canBuildStructure(whichTown->t,which)==7)
  264. {
  265. cout << "built " << b->Name() << "." << endl;
  266. cg.m_cb->buildBuilding(whichTown->t,which);
  267. for(int i = 0; b && i < b->resources.size();i++)
  268. hgs.resourceAmounts[i]-=b->resources[i];
  269. whichTown->hasBuilt=true;
  270. }
  271. break;
  272. case recruitCreatures:
  273. int ID = whichTown->creaturesToRecruit[which].second.back(); //buy upgraded if possible
  274. creature = &VLC->creh->creatures[ID];//cg.m_cb->getCCreatureByID(ID);
  275. int howMany = whichTown->creaturesToRecruit[which].first;
  276. for(int i = 0; i < creature->cost.size();i++)
  277. howMany = min(howMany,creature->cost[i]?hgs.resourceAmounts[i]/creature->cost[i]:INT_MAX);
  278. if(howMany == 0) cout << "tried to recruit without enough money.";
  279. cout << "recruiting " << howMany << " "<< creature->namePl << " (Total AI Strength " << creature->AIValue*howMany << ")." << endl;
  280. cg.m_cb->recruitCreatures(whichTown->t,ID,howMany);
  281. break;
  282. }
  283. }
  284. void CGeniusAI::fillObjectiveQueue(HypotheticalGameState & hgs)
  285. {
  286. objectiveQueue.clear();
  287. currentHeroObjectives.clear();
  288. currentTownObjectives.clear();
  289. for(std::vector <CGeniusAI::HypotheticalGameState::HeroModel>::iterator i = hgs.heroModels.begin(); i != hgs.heroModels.end(); i++)
  290. addHeroObjectives(*i,hgs);
  291. for(std::vector <CGeniusAI::HypotheticalGameState::TownModel>::iterator i = hgs.townModels.begin(); i != hgs.townModels.end(); i++)
  292. addTownObjectives(*i,hgs);
  293. for(std::set<CGeniusAI::HeroObjective>::iterator i = currentHeroObjectives.begin(); i != currentHeroObjectives.end(); i++)
  294. objectiveQueue.push_back(AIObjectivePtrCont(&(*i)));
  295. for(std::set<CGeniusAI::TownObjective>::iterator i = currentTownObjectives.begin(); i != currentTownObjectives.end(); i++)
  296. objectiveQueue.push_back(AIObjectivePtrCont(&(*i)));
  297. }
  298. CGeniusAI::AIObjective * CGeniusAI::getBestObjective()
  299. {
  300. trueGameState = HypotheticalGameState(*this);
  301. fillObjectiveQueue(trueGameState);
  302. if(!objectiveQueue.empty())
  303. return max_element(objectiveQueue.begin(),objectiveQueue.end())->obj;
  304. return NULL;
  305. }
  306. void CGeniusAI::yourTurn()
  307. {
  308. m_cb->waitTillRealize = true;
  309. static int seed = rand();
  310. srand(seed);
  311. if(firstTurn)
  312. {
  313. //m_cb->sendMessage("vcmieagles");
  314. //m_cb->sendMessage("vcmiformenos");
  315. //m_cb->sendMessage("vcmiformenos");
  316. firstTurn = false;
  317. }
  318. //////////////TODO: replace with updates. Also add suspected objects list./////////
  319. knownVisitableObjects.clear();
  320. int3 pos = m_cb->getMapSize();
  321. for(int x = 0;x<pos.x;x++)
  322. for(int y = 0;y<pos.y;y++)
  323. for(int z = 0;z<pos.z;z++)
  324. tileRevealed(int3(x,y,z));
  325. ///////////////////////////////////////////////////////////////////////////////////
  326. reportResources();
  327. turn++;
  328. AIObjective * objective;
  329. while((objective = getBestObjective())!=NULL)
  330. objective->fulfill(*this,trueGameState);
  331. seed = rand();
  332. m_cb->endTurn();
  333. m_cb->waitTillRealize = false;
  334. }
  335. void CGeniusAI::heroKilled(const CGHeroInstance * hero)
  336. {
  337. }
  338. void CGeniusAI::heroCreated(const CGHeroInstance *hero)
  339. {
  340. }
  341. void CGeniusAI::tileRevealed(int3 pos)
  342. {
  343. std::vector < const CGObjectInstance * > objects = m_cb->getVisitableObjs(pos);
  344. for(std::vector < const CGObjectInstance * >::iterator o = objects.begin();o!=objects.end();o++)
  345. knownVisitableObjects.insert(*o);
  346. objects = m_cb->getFlaggableObjects(pos);
  347. for(std::vector < const CGObjectInstance * >::iterator o = objects.begin();o!=objects.end();o++)
  348. knownVisitableObjects.insert(*o);
  349. }
  350. void CGeniusAI::newObject(const CGObjectInstance * obj) //eg. ship built in shipyard
  351. {
  352. knownVisitableObjects.insert(obj);
  353. }
  354. void CGeniusAI::objectRemoved(const CGObjectInstance *obj) //eg. collected resource, picked artifact, beaten hero
  355. {
  356. std::set <AIObjectContainer>::iterator o = knownVisitableObjects.find(obj);
  357. if(o!=knownVisitableObjects.end())
  358. knownVisitableObjects.erase(o);
  359. }
  360. void CGeniusAI::tileHidden(int3 pos)
  361. {
  362. }
  363. void CGeniusAI::heroMoved(const TryMoveHero &TMH)
  364. {
  365. //DbgBox("** CGeniusAI::heroMoved **");
  366. }
  367. void CGeniusAI::heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback)
  368. {
  369. callback(rand() % skills.size());
  370. }
  371. void GeniusAI::CGeniusAI::showGarrisonDialog( const CArmedInstance *up, const CGHeroInstance *down, boost::function<void()> &onEnd )
  372. {
  373. onEnd();
  374. }
  375. void GeniusAI::CGeniusAI::playerBlocked( int reason )
  376. {
  377. if(reason == 0) //battle is coming...
  378. {
  379. m_state.setn(UPCOMING_BATTLE);
  380. }
  381. }
  382. void GeniusAI::CGeniusAI::battleResultsApplied()
  383. {
  384. assert(m_state.get() == ENDING_BATTLE);
  385. m_state.setn(NO_BATTLE);
  386. }
  387. void CGeniusAI::showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, const int soundID, bool selection, bool cancel)
  388. {
  389. m_cb->selectionMade(cancel ? 0 : 1, askID);
  390. }
  391. /**
  392. * occurs AFTER every action taken by any stack or by the hero
  393. */
  394. void CGeniusAI::actionFinished(const BattleAction *action)
  395. {
  396. std::string message("\t\tCGeniusAI::actionFinished - type(");
  397. message += boost::lexical_cast<std::string>((unsigned)action->actionType);
  398. message += "), side(";
  399. message += boost::lexical_cast<std::string>((unsigned)action->side);
  400. message += ")";
  401. DbgBox(message.c_str());
  402. }
  403. /**
  404. * occurs BEFORE every action taken by any stack or by the hero
  405. */
  406. void CGeniusAI::actionStarted(const BattleAction *action)
  407. {
  408. std::string message("\t\tCGeniusAI::actionStarted - type(");
  409. message += boost::lexical_cast<std::string>((unsigned)action->actionType);
  410. message += "), side(";
  411. message += boost::lexical_cast<std::string>((unsigned)action->side);
  412. message += ")";
  413. DbgBox(message.c_str());
  414. }
  415. /**
  416. * called when stack is performing attack
  417. */
  418. void CGeniusAI::battleAttack(BattleAttack *ba)
  419. {
  420. DbgBox("\t\t\tCGeniusAI::battleAttack");
  421. }
  422. /**
  423. * called when stack receives damage (after battleAttack())
  424. */
  425. void CGeniusAI::battleStacksAttacked(std::set<BattleStackAttacked> & bsa)
  426. {
  427. DbgBox("\t\t\tCGeniusAI::battleStacksAttacked");
  428. }
  429. /**
  430. * called by engine when battle starts; side=0 - left, side=1 - right
  431. */
  432. void CGeniusAI::battleStart(CCreatureSet *army1, CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side)
  433. {
  434. assert(!m_battleLogic);
  435. assert(playerID > PLAYER_LIMIT || m_state.get() == UPCOMING_BATTLE); //we have been informed that battle will start (or we are neutral AI)
  436. m_state.setn(ONGOING_BATTLE);
  437. m_battleLogic = new BattleAI::CBattleLogic(m_cb, army1, army2, tile, hero1, hero2, side);
  438. DbgBox("** CGeniusAI::battleStart **");
  439. }
  440. /**
  441. *
  442. */
  443. void CGeniusAI::battleEnd(BattleResult *br)
  444. {
  445. /*switch(br->winner)
  446. {
  447. case 0: std::cout << "The winner is the attacker." << std::endl;break;
  448. case 1: std::cout << "The winner is the defender." << std::endl;break;
  449. case 2: std::cout << "It's a draw." << std::endl;break;
  450. };*/
  451. delete m_battleLogic;
  452. m_battleLogic = NULL;
  453. assert(m_state.get() == ONGOING_BATTLE);
  454. m_state.setn(ENDING_BATTLE);
  455. DbgBox("** CGeniusAI::battleEnd **");
  456. }
  457. /**
  458. * called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
  459. */
  460. void CGeniusAI::battleNewRound(int round)
  461. {
  462. std::string message("\tCGeniusAI::battleNewRound - ");
  463. message += boost::lexical_cast<std::string>(round);
  464. DbgBox(message.c_str());
  465. m_battleLogic->SetCurrentTurn(round);
  466. }
  467. /**
  468. *
  469. */
  470. void CGeniusAI::battleStackMoved(int ID, int dest, int distance, bool end)
  471. {
  472. std::string message("\t\t\tCGeniusAI::battleStackMoved ID(");
  473. message += boost::lexical_cast<std::string>(ID);
  474. message += "), dest(";
  475. message += boost::lexical_cast<std::string>(dest);
  476. message += ")";
  477. DbgBox(message.c_str());
  478. }
  479. /**
  480. *
  481. */
  482. void CGeniusAI::battleSpellCast(SpellCast *sc)
  483. {
  484. DbgBox("\t\t\tCGeniusAI::battleSpellCast");
  485. }
  486. /**
  487. * called when battlefield is prepared, prior the battle beginning
  488. */
  489. void CGeniusAI::battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles)
  490. {
  491. DbgBox("CGeniusAI::battlefieldPrepared");
  492. }
  493. /**
  494. *
  495. */
  496. void CGeniusAI::battleStackMoved(int ID, int dest, bool startMoving, bool endMoving)
  497. {
  498. DbgBox("\t\t\tCGeniusAI::battleStackMoved");
  499. }
  500. /**
  501. *
  502. */
  503. void CGeniusAI::battleStackAttacking(int ID, int dest)
  504. {
  505. DbgBox("\t\t\tCGeniusAI::battleStackAttacking");
  506. }
  507. /**
  508. *
  509. */
  510. void CGeniusAI::battleStackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting)
  511. {
  512. DbgBox("\t\t\tCGeniusAI::battleStackIsAttacked");
  513. }
  514. /**
  515. * called when it's turn of that stack
  516. */
  517. BattleAction CGeniusAI::activeStack(int stackID)
  518. {
  519. std::string message("\t\t\tCGeniusAI::activeStack stackID(");
  520. message += boost::lexical_cast<std::string>(stackID);
  521. message += ")";
  522. DbgBox(message.c_str());
  523. return m_battleLogic->MakeDecision(stackID);
  524. };