mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-31 22:05:10 +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::vector<int> pathsToDefend;
|
||||||
std::map<const CGHeroInstance *, std::vector<int>> defferedPaths;
|
std::map<const CGHeroInstance *, std::vector<int>> defferedPaths;
|
||||||
|
AIPath* closestWay = nullptr;
|
||||||
|
|
||||||
for(int i = 0; i < paths.size(); i++)
|
for(int i = 0; i < paths.size(); i++)
|
||||||
{
|
{
|
||||||
auto & path = paths[i];
|
auto & path = paths[i];
|
||||||
|
|
||||||
|
if (!closestWay || path.movementCost() < closestWay->movementCost())
|
||||||
|
closestWay = &path;
|
||||||
|
|
||||||
#if NKAI_TRACE_LEVEL >= 1
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace(
|
logAi->trace(
|
||||||
"Hero %s can defend town with force %lld in %s turns, cost: %f, path: %s",
|
"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());
|
town->getObjectName());
|
||||||
#endif
|
#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);
|
composition.addNextSequence(sequence);
|
||||||
|
|
||||||
auto firstBlockedAction = path.getFirstBlockedAction();
|
auto firstBlockedAction = path.getFirstBlockedAction();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user