1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

- Tweaks for GatherArmy

- Tweaks for exploration
- Increased default priority of BuyArmy, SIGNIFICANT improvement!
This commit is contained in:
DJWarmonger 2018-08-08 12:38:32 +02:00
parent a9ef8fe32f
commit d07a77f34b
3 changed files with 15 additions and 15 deletions

View File

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

View File

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

View File

@ -2582,13 +2582,13 @@ int3 VCAI::explorationNewPoint(HeroPtr h)
float ourValue = (float)howManyTilesWillBeDiscovered(tile, radius, cbp, h) / (path.nodes.size() + 1); //+1 prevents erratic jumps float ourValue = (float)howManyTilesWillBeDiscovered(tile, radius, cbp, h) / (path.nodes.size() + 1); //+1 prevents erratic jumps
if(ourValue > bestValue) //avoid costly checks of tiles that don't reveal much if(ourValue > bestValue) //avoid costly checks of tiles that don't reveal much
{
if(isSafeToVisit(h, tile))
{ {
auto obj = cb->getTopObj(tile); auto obj = cb->getTopObj(tile);
if (obj) if (obj)
if(obj->blockVisit && !isObjectRemovable(obj)) //we can't stand on that object if (obj->blockVisit && !isObjectRemovable(obj)) //we can't stand on that object
continue; continue;
if(isSafeToVisit(h, tile))
{
bestTile = tile; bestTile = tile;
bestValue = ourValue; bestValue = ourValue;
} }
@ -2632,14 +2632,14 @@ int3 VCAI::explorationDesperate(HeroPtr h)
auto t = sm->firstTileToGet(h, tile); auto t = sm->firstTileToGet(h, tile);
if(t.valid()) 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); ui64 ourDanger = evaluateDanger(t, h.h);
if(ourDanger < lowestDanger) 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 if(!ourDanger) //at least one safe place found
return t; return t;