mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
AI should only defend with one hero, not several who won't fit into the city anyways
This commit is contained in:
parent
97111328a8
commit
d3987d8456
@ -214,11 +214,15 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
std::vector<int> pathsToDefend;
|
||||
std::map<const CGHeroInstance *, std::vector<int>> defferedPaths;
|
||||
AIPath* closestWay = nullptr;
|
||||
|
||||
for(int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
auto & path = paths[i];
|
||||
|
||||
if (!closestWay || path.movementCost() < closestWay->movementCost())
|
||||
closestWay = &path;
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Hero %s can defend town with force %lld in %s turns, cost: %f, path: %s",
|
||||
@ -382,7 +386,14 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
town->getObjectName());
|
||||
#endif
|
||||
|
||||
sequence.push_back(sptr(ExecuteHeroChain(path, town)));
|
||||
ExecuteHeroChain heroChain = ExecuteHeroChain(path, town);
|
||||
|
||||
if (closestWay)
|
||||
{
|
||||
heroChain.closestWayRatio = closestWay->movementCost() / heroChain.getPath().movementCost();
|
||||
}
|
||||
|
||||
sequence.push_back(sptr(heroChain));
|
||||
composition.addNextSequence(sequence);
|
||||
|
||||
auto firstBlockedAction = path.getFirstBlockedAction();
|
||||
|
Loading…
x
Reference in New Issue
Block a user