From d07a77f34b26d7a1c167e4cf3a5764d7f5af40cc Mon Sep 17 00:00:00 2001 From: DJWarmonger Date: Wed, 8 Aug 2018 12:38:32 +0200 Subject: [PATCH] - Tweaks for GatherArmy - Tweaks for exploration - Increased default priority of BuyArmy, SIGNIFICANT improvement! --- AI/VCAI/Goals.cpp | 10 +++++----- AI/VCAI/Goals.h | 2 +- AI/VCAI/VCAI.cpp | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index f0efe253d..228826d5d 100644 --- a/AI/VCAI/Goals.cpp +++ b/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; diff --git a/AI/VCAI/Goals.h b/AI/VCAI/Goals.h index 36e208623..6adcea7b4 100644 --- a/AI/VCAI/Goals.h +++ b/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; diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 6c5094672..5eb6b227a 100644 --- a/AI/VCAI/VCAI.cpp +++ b/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;