浏览代码

Army-hiring

Supressing hiring army on turn one seems just bad. Starting the main-hero as strong as possible seems like a good idea to me and hiring the available troops outright will help achieve that goal.

However, if there's a hero for hire, who has army with him that is a better deal, we hire that one first.
Xilmi 1 年之前
父节点
当前提交
663ca23f6f
共有 1 个文件被更改,包括 16 次插入8 次删除
  1. 16 8
      AI/Nullkiller/Behaviors/BuyArmyBehavior.cpp

+ 16 - 8
AI/Nullkiller/Behaviors/BuyArmyBehavior.cpp

@@ -28,9 +28,6 @@ Goals::TGoalVec BuyArmyBehavior::decompose(const Nullkiller * ai) const
 {
 	Goals::TGoalVec tasks;
 
-	if(ai->cb->getDate(Date::DAY) == 1)
-		return tasks;
-		
 	auto heroes = cb->getHeroesInfo();
 
 	if(heroes.empty())
@@ -40,17 +37,28 @@ Goals::TGoalVec BuyArmyBehavior::decompose(const Nullkiller * ai) const
 
 	for(auto town : cb->getTownsInfo())
 	{
+		//If we can recruit a hero that comes with more army than he costs, we are better off spending our gold on them
+		if (ai->heroManager->canRecruitHero(town))
+		{
+			auto availableHeroes = ai->cb->getAvailableHeroes(town);
+			for (auto hero : availableHeroes)
+			{
+				if (hero->getArmyCost() > GameConstants::HERO_GOLD_COST)
+					return tasks;
+			}
+		}
+
+		if (ai->buildAnalyzer->isGoldPressureHigh() && !town->hasBuilt(BuildingID::CITY_HALL))
+		{
+			return tasks;
+		}
+		
 		auto townArmyAvailableToBuy = ai->armyManager->getArmyAvailableToBuyAsCCreatureSet(
 			town,
 			ai->getFreeResources());
 
 		for(const CGHeroInstance * targetHero : heroes)
 		{
-			if(ai->buildAnalyzer->isGoldPressureHigh()	&& !town->hasBuilt(BuildingID::CITY_HALL))
-			{
-				continue;
-			}
-
 			if(ai->heroManager->getHeroRole(targetHero) == HeroRole::MAIN)
 			{
 				auto reinforcement = ai->armyManager->howManyReinforcementsCanGet(