mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-17 20:58:07 +02:00
Merge pull request #4612 from vcmi/nkai-treat-pandora-as-blocker
NKAI: pandora as blocker object
This commit is contained in:
commit
894c88defc
@ -649,7 +649,14 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
|
||||
auto danger = nullkiller->dangerEvaluator->evaluateDanger(target, hero.get());
|
||||
auto ratio = static_cast<float>(danger) / hero->getTotalStrength();
|
||||
|
||||
answer = topObj->id == goalObjectID; // no if we do not aim to visit this object
|
||||
answer = 1;
|
||||
|
||||
if(topObj->id != goalObjectID && nullkiller->dangerEvaluator->evaluateDanger(topObj) > 0)
|
||||
{
|
||||
// no if we do not aim to visit this object
|
||||
answer = 0;
|
||||
}
|
||||
|
||||
logAi->trace("Query hook: %s(%s) by %s danger ratio %f", target.toString(), topObj->getObjectName(), hero.name(), ratio);
|
||||
|
||||
if(cb->getObj(goalObjectID, false))
|
||||
|
@ -146,6 +146,13 @@ std::optional<const CGObjectInstance *> ObjectClusterizer::getBlocker(const AIPa
|
||||
return blocker;
|
||||
}
|
||||
|
||||
auto danger = ai->dangerEvaluator->evaluateDanger(blocker);
|
||||
|
||||
if(danger > 0 && blocker->isBlockedVisitable() && isObjectRemovable(blocker))
|
||||
{
|
||||
return blocker;
|
||||
}
|
||||
|
||||
return std::optional< const CGObjectInstance *>();
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
|
||||
return;
|
||||
}
|
||||
|
||||
auto danger = ai->nullkiller->pathfinder->getStorage()->evaluateDanger(target, hero, true);
|
||||
auto danger = ai->nullkiller->dangerEvaluator->evaluateDanger(target, hero, true);
|
||||
|
||||
if(danger > 0 || !ai->moveHeroToTile(target, hero))
|
||||
{
|
||||
|
@ -97,8 +97,6 @@ AINodeStorage::AINodeStorage(const Nullkiller * ai, const int3 & Sizes)
|
||||
{
|
||||
accessibility = std::make_unique<boost::multi_array<EPathAccessibility, 4>>(
|
||||
boost::extents[sizes.z][sizes.x][sizes.y][EPathfindingLayer::NUM_LAYERS]);
|
||||
|
||||
dangerEvaluator.reset(new FuzzyHelper(ai));
|
||||
}
|
||||
|
||||
AINodeStorage::~AINodeStorage() = default;
|
||||
@ -1419,7 +1417,7 @@ void AINodeStorage::calculateChainInfo(std::vector<AIPath> & paths, const int3 &
|
||||
path.targetHero = node.actor->hero;
|
||||
path.heroArmy = node.actor->creatureSet;
|
||||
path.armyLoss = node.armyLoss;
|
||||
path.targetObjectDanger = evaluateDanger(pos, path.targetHero, !node.actor->allowBattle);
|
||||
path.targetObjectDanger = ai->dangerEvaluator->evaluateDanger(pos, path.targetHero, !node.actor->allowBattle);
|
||||
|
||||
if(path.targetObjectDanger > 0)
|
||||
{
|
||||
|
@ -176,7 +176,6 @@ private:
|
||||
|
||||
const CPlayerSpecificInfoCallback * cb;
|
||||
const Nullkiller * ai;
|
||||
std::unique_ptr<FuzzyHelper> dangerEvaluator;
|
||||
AISharedStorage nodes;
|
||||
std::vector<std::shared_ptr<ChainActor>> actors;
|
||||
std::vector<CGPathNode *> heroChain;
|
||||
@ -285,11 +284,6 @@ public:
|
||||
bool calculateHeroChain();
|
||||
bool calculateHeroChainFinal();
|
||||
|
||||
inline uint64_t evaluateDanger(const int3 & tile, const CGHeroInstance * hero, bool checkGuards) const
|
||||
{
|
||||
return dangerEvaluator->evaluateDanger(tile, hero, checkGuards);
|
||||
}
|
||||
|
||||
uint64_t evaluateArmyLoss(const CGHeroInstance * hero, uint64_t armyValue, uint64_t danger) const;
|
||||
|
||||
inline EPathAccessibility getAccessibility(const int3 & tile, EPathfindingLayer layer) const
|
||||
|
@ -291,7 +291,7 @@ void GraphPaths::addChainInfo(std::vector<AIPath> & paths, int3 tile, const CGHe
|
||||
}
|
||||
|
||||
path.armyLoss += loss;
|
||||
path.targetObjectDanger = ai->pathfinder->getStorage()->evaluateDanger(tile, path.targetHero, !allowBattle);
|
||||
path.targetObjectDanger = ai->dangerEvaluator->evaluateDanger(tile, path.targetHero, !allowBattle);
|
||||
path.targetObjectArmyLoss = ai->pathfinder->getStorage()->evaluateArmyLoss(path.targetHero, path.heroArmy->getArmyStrength(), path.targetObjectDanger);
|
||||
|
||||
paths.push_back(path);
|
||||
@ -356,7 +356,7 @@ void GraphPaths::quickAddChainInfoWithBlocker(std::vector<AIPath> & paths, int3
|
||||
path.heroArmy = entryPath.heroArmy;
|
||||
path.exchangeCount = entryPath.exchangeCount;
|
||||
path.armyLoss = entryPath.armyLoss + ai->pathfinder->getStorage()->evaluateArmyLoss(path.targetHero, path.heroArmy->getArmyStrength(), danger);
|
||||
path.targetObjectDanger = ai->pathfinder->getStorage()->evaluateDanger(tile, path.targetHero, !allowBattle);
|
||||
path.targetObjectDanger = ai->dangerEvaluator->evaluateDanger(tile, path.targetHero, !allowBattle);
|
||||
path.targetObjectArmyLoss = ai->pathfinder->getStorage()->evaluateArmyLoss(path.targetHero, path.heroArmy->getArmyStrength(), path.targetObjectDanger);
|
||||
|
||||
AIPathNodeInfo n;
|
||||
|
@ -164,7 +164,7 @@ void ObjectGraphCalculator::calculateConnections(const int3 & pos, std::vector<A
|
||||
auto from = path.targetHero->visitablePos();
|
||||
auto fromObj = actorObjectMap[path.targetHero];
|
||||
|
||||
auto danger = ai->pathfinder->getStorage()->evaluateDanger(pos, path.targetHero, true);
|
||||
auto danger = ai->dangerEvaluator->evaluateDanger(pos, path.targetHero, true);
|
||||
auto updated = target->tryAddConnection(
|
||||
from,
|
||||
pos,
|
||||
@ -220,7 +220,7 @@ void ObjectGraphCalculator::calculateConnections(const int3 & pos, std::vector<A
|
||||
continue;
|
||||
}
|
||||
|
||||
auto danger = ai->pathfinder->getStorage()->evaluateDanger(pos2, path1.targetHero, true);
|
||||
auto danger = ai->dangerEvaluator->evaluateDanger(pos2, path1.targetHero, true);
|
||||
|
||||
auto updated = target->tryAddConnection(
|
||||
pos1,
|
||||
|
@ -227,7 +227,7 @@ namespace AIPathfinding
|
||||
return false;
|
||||
}
|
||||
|
||||
auto danger = nodeStorage->evaluateDanger(destination.coord, nodeStorage->getHero(destination.node), true);
|
||||
auto danger = ai->dangerEvaluator->evaluateDanger(destination.coord, nodeStorage->getHero(destination.node), true);
|
||||
|
||||
if(danger)
|
||||
{
|
||||
@ -313,7 +313,7 @@ namespace AIPathfinding
|
||||
}
|
||||
|
||||
auto hero = nodeStorage->getHero(source.node);
|
||||
uint64_t danger = nodeStorage->evaluateDanger(destination.coord, hero, true);
|
||||
uint64_t danger = ai->dangerEvaluator->evaluateDanger(destination.coord, hero, true);
|
||||
uint64_t actualArmyValue = srcNode->actor->armyValue - srcNode->armyLoss;
|
||||
uint64_t loss = nodeStorage->evaluateArmyLoss(hero, actualArmyValue, danger);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user