Prechádzať zdrojové kódy

- Tweaks for GatherArmy
- Tweaks for exploration
- Increased default priority of BuyArmy, SIGNIFICANT improvement!

DJWarmonger 7 rokov pred
rodič
commit
d07a77f34b
3 zmenil súbory, kde vykonal 15 pridanie a 15 odobranie
  1. 5 5
      AI/VCAI/Goals.cpp
  2. 1 1
      AI/VCAI/Goals.h
  3. 9 9
      AI/VCAI/VCAI.cpp

+ 5 - 5
AI/VCAI/Goals.cpp

@@ -1522,7 +1522,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
 			return true;
 		else if(!ai->isAccessibleForHero(heroDummy->visitablePos(), h, true))
 			return true;
-		else if(!ai->canGetArmy(heroDummy.h, h))
+		else if(!ai->canGetArmy(heroDummy.h, h)) //TODO: return actual aiValue
 			return true;
 		else if(ai->getGoal(h)->goalType == Goals::GATHER_ARMY)
 			return true;
@@ -1558,7 +1558,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
 						{
 							auto creature = VLC->creh->creatures[creatureID];
 							if(ah->freeResources().canAfford(creature->cost))
-								objs.push_back(obj);
+								objs.push_back(obj); //TODO: reserve resources?
 						}
 					}
 				}
@@ -1594,10 +1594,10 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
 
 	if(ret.empty())
 	{
-		if(hero == ai->primaryHero() || value >= 1.1f) // FIXME: check PR388
+		if(hero == ai->primaryHero())
 			ret.push_back(sptr(Goals::Explore()));
-		else //workaround to break loop - seemingly there are no ways to explore left
-			throw goalFulfilledException(sptr(Goals::GatherArmy(0).sethero(hero)));
+		else
+			throw cannotFulfillGoalException("No ways to gather army");
 	}
 
 	return ret;

+ 1 - 1
AI/VCAI/Goals.h

@@ -331,7 +331,7 @@ public:
 	{
 		town = Town; //where to buy this army
 		value = val; //expressed in AI unit strength
-		priority = 2;//TODO: evaluate?
+		priority = 3;//TODO: evaluate?
 	}
 	bool operator==(AbstractGoal & g) override;
 	bool fulfillsMe(TSubgoal goal) override;

+ 9 - 9
AI/VCAI/VCAI.cpp

@@ -2583,12 +2583,12 @@ int3 VCAI::explorationNewPoint(HeroPtr h)
 
 			if(ourValue > bestValue) //avoid costly checks of tiles that don't reveal much
 			{
+				auto obj = cb->getTopObj(tile);
+				if (obj)
+					if (obj->blockVisit && !isObjectRemovable(obj)) //we can't stand on that object
+						continue;
 				if(isSafeToVisit(h, tile))
 				{
-					auto obj = cb->getTopObj(tile);
-					if (obj)
-						if(obj->blockVisit && !isObjectRemovable(obj)) //we can't stand on that object
-							continue;
 					bestTile = tile;
 					bestValue = ourValue;
 				}
@@ -2632,14 +2632,14 @@ int3 VCAI::explorationDesperate(HeroPtr h)
 			auto t = sm->firstTileToGet(h, tile);
 			if(t.valid())
 			{
+				auto obj = cb->getTopObj(t);
+				if (obj)
+					if (obj->blockVisit && !isObjectRemovable(obj)) //we can't stand on object or remove it
+						continue;
+
 				ui64 ourDanger = evaluateDanger(t, h.h);
 				if(ourDanger < lowestDanger)
 				{
-					auto obj = cb->getTopObj(t);
-					if (obj)
-						if (obj->blockVisit && !isObjectRemovable(obj)) //we can't stand on objct or remove it
-							continue;
-
 					if(!ourDanger) //at least one safe place found
 						return t;