NKAI: avoid writing to commited tiles when calculating hero chain

This commit is contained in:
Andrii Danylchenko committed 2024-01-21 10:18:39 +02:00
1 parent d8a96066c6
commit 708e0d1107
2 files changed
+17 -5

No files matched your search

+15 -4
View File
@@ -35,6 +35,8 @@ const uint64_t MIN_ARMY_STRENGTH_FOR_CHAIN = 5000;
const uint64_t MIN_ARMY_STRENGTH_FOR_NEXT_ACTOR = 1000;
const uint64_t CHAIN_MAX_DEPTH = 4;
const bool DO_NOT_SAVE_TO_COMMITED_TILES = false;
AISharedStorage::AISharedStorage(int3 sizes)
{
if(!shared){
@@ -265,7 +267,8 @@ void AINodeStorage::commit(
EPathNodeAction action,
int turn,
int movementLeft,
float cost) const
float cost,
bool saveToCommited) const
{
destination->action = action;
destination->setCost(cost);
@@ -291,7 +294,7 @@ void AINodeStorage::commit(
destination->actor->armyValue);
#endif
if(destination->turns <= heroChainTurn)
if(saveToCommited && destination->turns <= heroChainTurn)
{
commitedTiles.insert(destination->coord);
}
@@ -778,7 +781,14 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
continue;
}
storage.commit(exchangeNode, carrier, carrier->action, chainInfo.turns, chainInfo.moveRemains, chainInfo.getCost());
storage.commit(
exchangeNode,
carrier,
carrier->action,
chainInfo.turns,
chainInfo.moveRemains,
chainInfo.getCost(),
DO_NOT_SAVE_TO_COMMITED_TILES);
if(carrier->specialAction || carrier->chainOther)
{
@@ -1070,7 +1080,8 @@ struct TowmPortalFinder
EPathNodeAction::TELEPORT_NORMAL,
bestNode->turns,
bestNode->moveRemains - movementNeeded,
movementCost);
movementCost,
DO_NOT_SAVE_TO_COMMITED_TILES);
node->theNodeBefore = bestNode;
node->addSpecialAction(std::make_shared<AIPathfinding::TownPortalAction>(targetTown));
+2 -1
View File
@@ -200,7 +200,8 @@ public:
EPathNodeAction action,
int turn,
int movementLeft,
float cost) const;
float cost,
bool saveToCommited = true) const;
inline const AIPathNode * getAINode(const CGPathNode * node) const
{