mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
cloned Nullkiller into Nullkiller2
This commit is contained in:
@@ -45,4 +45,5 @@ add_subdirectory(StupidAI)
|
||||
add_subdirectory(EmptyAI)
|
||||
if(ENABLE_NULLKILLER_AI)
|
||||
add_subdirectory(Nullkiller)
|
||||
add_subdirectory(Nullkiller2)
|
||||
endif()
|
||||
|
||||
@@ -75,7 +75,7 @@ AIGateway::AIGateway()
|
||||
LOG_TRACE(logAi);
|
||||
destinationTeleport = ObjectInstanceID();
|
||||
destinationTeleportPos = int3(-1);
|
||||
nullkiller.reset(new Nullkiller());
|
||||
nullkiller2.reset(new Nullkiller2());
|
||||
asyncTasks = std::make_unique<AsyncRunner>();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ AIGateway::~AIGateway()
|
||||
{
|
||||
LOG_TRACE(logAi);
|
||||
finish();
|
||||
nullkiller.reset();
|
||||
nullkiller2.reset();
|
||||
}
|
||||
|
||||
void AIGateway::availableCreaturesChanged(const CGDwelling * town)
|
||||
@@ -102,7 +102,7 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
|
||||
if(!hero)
|
||||
validateObject(details.id); //enemy hero may have left visible area
|
||||
|
||||
nullkiller->invalidatePathfinderData();
|
||||
nullkiller2->invalidatePathfinderData();
|
||||
|
||||
const int3 from = hero ? hero->convertToVisitablePos(details.start) : (details.start - int3(0,1,0));
|
||||
const int3 to = hero ? hero->convertToVisitablePos(details.end) : (details.end - int3(0,1,0));
|
||||
@@ -120,7 +120,7 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
|
||||
{
|
||||
if(o1->ID == Obj::SUBTERRANEAN_GATE && o1->ID == o2->ID) // We need to only add subterranean gates in knownSubterraneanGates. Used for features not yet ported to use teleport channels
|
||||
{
|
||||
nullkiller->memory->addSubterraneanGate(o1, o2);
|
||||
nullkiller2->memory->addSubterraneanGate(o1, o2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ void AIGateway::gameOver(PlayerColor player, const EVictoryLossCheckResult & vic
|
||||
logAi->debug("AIGateway: Player %d (%s) lost. It's me. What a disappointment! :(", player, player.toString());
|
||||
}
|
||||
|
||||
nullkiller->makingTurnInterrupption.interruptThread();
|
||||
nullkiller2->makingTurnInterrupption.interruptThread();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,8 +250,8 @@ void AIGateway::heroVisit(const CGHeroInstance * visitor, const CGObjectInstance
|
||||
|
||||
if(start && visitedObj) //we can end visit with null object, anyway
|
||||
{
|
||||
nullkiller->memory->markObjectVisited(visitedObj);
|
||||
nullkiller->objectClusterizer->invalidate(visitedObj->id);
|
||||
nullkiller2->memory->markObjectVisited(visitedObj);
|
||||
nullkiller2->objectClusterizer->invalidate(visitedObj->id);
|
||||
}
|
||||
|
||||
status.heroVisit(visitedObj, start);
|
||||
@@ -274,7 +274,7 @@ void AIGateway::tileHidden(const FowTilesType & pos)
|
||||
LOG_TRACE(logAi);
|
||||
NET_EVENT_HANDLER;
|
||||
|
||||
nullkiller->memory->removeInvisibleObjects(myCb.get());
|
||||
nullkiller2->memory->removeInvisibleObjects(myCb.get());
|
||||
}
|
||||
|
||||
void AIGateway::tileRevealed(const FowTilesType & pos)
|
||||
@@ -287,8 +287,8 @@ void AIGateway::tileRevealed(const FowTilesType & pos)
|
||||
addVisitableObj(obj);
|
||||
}
|
||||
|
||||
if (nullkiller->settings->isUpdateHitmapOnTileReveal() && !pos.empty())
|
||||
nullkiller->dangerHitMap->resetTileOwners();
|
||||
if (nullkiller2->settings->isUpdateHitmapOnTileReveal() && !pos.empty())
|
||||
nullkiller2->dangerHitMap->resetTileOwners();
|
||||
}
|
||||
|
||||
void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query)
|
||||
@@ -317,7 +317,7 @@ void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID her
|
||||
}
|
||||
else
|
||||
{
|
||||
if(nullkiller->isActive(firstHero))
|
||||
if(nullkiller2->isActive(firstHero))
|
||||
transferFrom2to1(secondHero, firstHero);
|
||||
else
|
||||
transferFrom2to1(firstHero, secondHero);
|
||||
@@ -368,7 +368,7 @@ void AIGateway::newObject(const CGObjectInstance * obj)
|
||||
{
|
||||
LOG_TRACE(logAi);
|
||||
NET_EVENT_HANDLER;
|
||||
nullkiller->invalidatePathfinderData();
|
||||
nullkiller2->invalidatePathfinderData();
|
||||
if(obj->isVisitable())
|
||||
addVisitableObj(obj);
|
||||
}
|
||||
@@ -380,15 +380,15 @@ void AIGateway::objectRemoved(const CGObjectInstance * obj, const PlayerColor &
|
||||
LOG_TRACE(logAi);
|
||||
NET_EVENT_HANDLER;
|
||||
|
||||
if(!nullkiller) // crash protection
|
||||
if(!nullkiller2) // crash protection
|
||||
return;
|
||||
|
||||
nullkiller->memory->removeFromMemory(obj);
|
||||
nullkiller->objectClusterizer->onObjectRemoved(obj->id);
|
||||
nullkiller2->memory->removeFromMemory(obj);
|
||||
nullkiller2->objectClusterizer->onObjectRemoved(obj->id);
|
||||
|
||||
if(nullkiller->baseGraph && nullkiller->isObjectGraphAllowed())
|
||||
if(nullkiller2->baseGraph && nullkiller2->isObjectGraphAllowed())
|
||||
{
|
||||
nullkiller->baseGraph->removeObject(obj);
|
||||
nullkiller2->baseGraph->removeObject(obj);
|
||||
}
|
||||
|
||||
if(obj->ID == Obj::HERO && obj->tempOwner == playerID)
|
||||
@@ -397,10 +397,10 @@ void AIGateway::objectRemoved(const CGObjectInstance * obj, const PlayerColor &
|
||||
}
|
||||
|
||||
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
|
||||
nullkiller->dangerHitMap->resetHitmap();
|
||||
nullkiller2->dangerHitMap->resetHitmap();
|
||||
|
||||
if(obj->ID == Obj::TOWN)
|
||||
nullkiller->dangerHitMap->resetTileOwners();
|
||||
nullkiller2->dangerHitMap->resetTileOwners();
|
||||
}
|
||||
|
||||
void AIGateway::showHillFortWindow(const CGObjectInstance * object, const CGHeroInstance * visitor)
|
||||
@@ -419,7 +419,7 @@ void AIGateway::heroCreated(const CGHeroInstance * h)
|
||||
{
|
||||
LOG_TRACE(logAi);
|
||||
NET_EVENT_HANDLER;
|
||||
nullkiller->invalidatePathfinderData(); // new hero needs to look around
|
||||
nullkiller2->invalidatePathfinderData(); // new hero needs to look around
|
||||
}
|
||||
|
||||
void AIGateway::advmapSpellCast(const CGHeroInstance * caster, SpellID spellID)
|
||||
@@ -503,7 +503,7 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
|
||||
auto relations = myCb->getPlayerRelations(playerID, sop->identifier.as<PlayerColor>());
|
||||
auto obj = myCb->getObj(sop->id, false);
|
||||
|
||||
if(!nullkiller) // crash protection
|
||||
if(!nullkiller2) // crash protection
|
||||
return;
|
||||
|
||||
if(obj)
|
||||
@@ -512,12 +512,12 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
|
||||
{
|
||||
//we want to visit objects owned by oppponents
|
||||
//addVisitableObj(obj); // TODO: Remove once save compatibility broken. In past owned objects were removed from this set
|
||||
nullkiller->memory->markObjectUnvisited(obj);
|
||||
nullkiller2->memory->markObjectUnvisited(obj);
|
||||
}
|
||||
else if(relations == PlayerRelations::SAME_PLAYER && obj->ID == Obj::TOWN)
|
||||
{
|
||||
// reevaluate defence for a new town
|
||||
nullkiller->dangerHitMap->resetHitmap();
|
||||
nullkiller2->dangerHitMap->resetHitmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -565,7 +565,7 @@ std::optional<BattleAction> AIGateway::makeSurrenderRetreatDecision(const Battle
|
||||
double fightRatio = ourStrength / (double)battleState.getEnemyStrength();
|
||||
|
||||
// if we have no towns - things are already bad, so retreat is not an option.
|
||||
if(cb->getTownsInfo().size() && ourStrength < nullkiller->settings->getRetreatThresholdAbsolute() && fightRatio < nullkiller->settings->getRetreatThresholdRelative() && battleState.canFlee)
|
||||
if(cb->getTownsInfo().size() && ourStrength < nullkiller2->settings->getRetreatThresholdAbsolute() && fightRatio < nullkiller2->settings->getRetreatThresholdRelative() && battleState.canFlee)
|
||||
{
|
||||
return BattleAction::makeRetreat(battleState.ourSide);
|
||||
}
|
||||
@@ -585,7 +585,7 @@ void AIGateway::initGameInterface(std::shared_ptr<Environment> env, std::shared_
|
||||
playerID = *myCb->getPlayerID();
|
||||
myCb->waitTillRealize = true;
|
||||
|
||||
nullkiller->init(CB, this);
|
||||
nullkiller2->init(CB, this);
|
||||
|
||||
retrieveVisitableObjs();
|
||||
}
|
||||
@@ -594,12 +594,12 @@ void AIGateway::yourTurn(QueryID queryID)
|
||||
{
|
||||
LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID);
|
||||
NET_EVENT_HANDLER;
|
||||
nullkiller->invalidatePathfinderData();
|
||||
nullkiller2->invalidatePathfinderData();
|
||||
status.addQuery(queryID, "YourTurn");
|
||||
executeActionAsync("yourTurn", [this, queryID](){ answerQuery(queryID, 0); });
|
||||
status.startedTurn();
|
||||
|
||||
nullkiller->makingTurnInterrupption.reset();
|
||||
nullkiller2->makingTurnInterrupption.reset();
|
||||
|
||||
asyncTasks->run([this]()
|
||||
{
|
||||
@@ -622,11 +622,11 @@ void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, s
|
||||
|
||||
if(hPtr.validAndSet())
|
||||
{
|
||||
std::unique_lock lockGuard(nullkiller->aiStateMutex);
|
||||
std::unique_lock lockGuard(nullkiller2->aiStateMutex);
|
||||
|
||||
nullkiller->heroManager->update();
|
||||
nullkiller2->heroManager->update();
|
||||
|
||||
sel = nullkiller->heroManager->selectBestSkill(hPtr, skills);
|
||||
sel = nullkiller2->heroManager->selectBestSkill(hPtr, skills);
|
||||
}
|
||||
|
||||
answerQuery(queryID, sel);
|
||||
@@ -648,8 +648,8 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
|
||||
status.addQuery(askID, boost::str(boost::format("Blocking dialog query with %d components - %s")
|
||||
% components.size() % text));
|
||||
|
||||
auto hero = nullkiller->getActiveHero();
|
||||
auto target = nullkiller->getTargetTile();
|
||||
auto hero = nullkiller2->getActiveHero();
|
||||
auto target = nullkiller2->getTargetTile();
|
||||
|
||||
if(!selection && cancel)
|
||||
{
|
||||
@@ -663,13 +663,13 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
|
||||
{
|
||||
auto topObj = objects.front()->id == hero->id ? objects.back() : objects.front();
|
||||
auto objType = topObj->ID; // top object should be our hero
|
||||
auto goalObjectID = nullkiller->getTargetObject();
|
||||
auto danger = nullkiller->dangerEvaluator->evaluateDanger(target, hero.get());
|
||||
auto goalObjectID = nullkiller2->getTargetObject();
|
||||
auto danger = nullkiller2->dangerEvaluator->evaluateDanger(target, hero.get());
|
||||
auto ratio = static_cast<float>(danger) / hero->getTotalStrength();
|
||||
|
||||
answer = true;
|
||||
|
||||
if(topObj->id != goalObjectID && nullkiller->dangerEvaluator->evaluateDanger(topObj) > 0)
|
||||
if(topObj->id != goalObjectID && nullkiller2->dangerEvaluator->evaluateDanger(topObj) > 0)
|
||||
{
|
||||
// no if we do not aim to visit this object
|
||||
answer = false;
|
||||
@@ -689,7 +689,7 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
|
||||
else if(objType == Obj::ARTIFACT || objType == Obj::RESOURCE)
|
||||
{
|
||||
bool dangerUnknown = danger == 0;
|
||||
bool dangerTooHigh = ratio * nullkiller->settings->getSafeAttackRatio() > 1;
|
||||
bool dangerTooHigh = ratio * nullkiller2->settings->getSafeAttackRatio() > 1;
|
||||
|
||||
answer = !dangerUnknown && !dangerTooHigh;
|
||||
}
|
||||
@@ -709,14 +709,14 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
|
||||
sel = components.size();
|
||||
|
||||
{
|
||||
std::unique_lock mxLock(nullkiller->aiStateMutex);
|
||||
std::unique_lock mxLock(nullkiller2->aiStateMutex);
|
||||
|
||||
// TODO: Find better way to understand it is Chest of Treasures
|
||||
if(hero.validAndSet()
|
||||
&& components.size() == 2
|
||||
&& components.front().type == ComponentType::RESOURCE
|
||||
&& (nullkiller->heroManager->getHeroRole(hero) != HeroRole::MAIN
|
||||
|| nullkiller->buildAnalyzer->isGoldPressureHigh()))
|
||||
&& (nullkiller2->heroManager->getHeroRole(hero) != HeroRole::MAIN
|
||||
|| nullkiller2->buildAnalyzer->isGoldPressureHigh()))
|
||||
{
|
||||
sel = 1;
|
||||
}
|
||||
@@ -734,7 +734,7 @@ void AIGateway::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelI
|
||||
int chosenExit = -1;
|
||||
if(impassable)
|
||||
{
|
||||
nullkiller->memory->knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
|
||||
nullkiller2->memory->knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
|
||||
}
|
||||
else if(destinationTeleport != ObjectInstanceID() && destinationTeleportPos.isValid())
|
||||
{
|
||||
@@ -782,7 +782,7 @@ void AIGateway::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstan
|
||||
//you can't request action from action-response thread
|
||||
executeActionAsync("showGarrisonDialog", [this, up, down, removableUnits, queryID]()
|
||||
{
|
||||
if(removableUnits && up->tempOwner == down->tempOwner && nullkiller->settings->isGarrisonTroopsUsageAllowed() && !cb->getStartInfo()->restrictedGarrisonsForAI())
|
||||
if(removableUnits && up->tempOwner == down->tempOwner && nullkiller2->settings->isGarrisonTroopsUsageAllowed() && !cb->getStartInfo()->restrictedGarrisonsForAI())
|
||||
{
|
||||
pickBestCreatures(down, up);
|
||||
}
|
||||
@@ -825,7 +825,7 @@ bool AIGateway::makePossibleUpgrades(const CArmedInstance * obj)
|
||||
int oldValue = s->getCreature()->getAIValue();
|
||||
int newValue = upgID.toCreature()->getAIValue();
|
||||
|
||||
if(newValue > oldValue && nullkiller->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->getCount()))
|
||||
if(newValue > oldValue && nullkiller2->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->getCount()))
|
||||
{
|
||||
myCb->upgradeCreature(obj, SlotID(i), upgID);
|
||||
upgraded = true;
|
||||
@@ -853,7 +853,7 @@ void AIGateway::makeTurn()
|
||||
|
||||
std::shared_lock gsLock(CGameState::mutex);
|
||||
|
||||
if(nullkiller->isOpenMap())
|
||||
if(nullkiller2->isOpenMap())
|
||||
{
|
||||
cb->sendMessage("vcmieagles");
|
||||
}
|
||||
@@ -862,11 +862,11 @@ void AIGateway::makeTurn()
|
||||
|
||||
if(cb->getDate(Date::DAY_OF_WEEK) == 1)
|
||||
{
|
||||
for(const CGObjectInstance * obj : nullkiller->memory->visitableObjs)
|
||||
for(const CGObjectInstance * obj : nullkiller2->memory->visitableObjs)
|
||||
{
|
||||
if(isWeeklyRevisitable(nullkiller.get(), obj))
|
||||
if(isWeeklyRevisitable(nullkiller2.get(), obj))
|
||||
{
|
||||
nullkiller->memory->markObjectUnvisited(obj);
|
||||
nullkiller2->memory->markObjectUnvisited(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -875,7 +875,7 @@ void AIGateway::makeTurn()
|
||||
try
|
||||
{
|
||||
#endif
|
||||
nullkiller->makeTurn();
|
||||
nullkiller2->makeTurn();
|
||||
|
||||
//for debug purpose
|
||||
for (auto h : cb->getHeroesInfo())
|
||||
@@ -917,13 +917,13 @@ void AIGateway::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h
|
||||
{
|
||||
makePossibleUpgrades(h.get());
|
||||
|
||||
std::unique_lock lockGuard(nullkiller->aiStateMutex);
|
||||
std::unique_lock lockGuard(nullkiller2->aiStateMutex);
|
||||
|
||||
if(!h->getVisitedTown()->getGarrisonHero() || !nullkiller->isHeroLocked(h->getVisitedTown()->getGarrisonHero()))
|
||||
if(!h->getVisitedTown()->getGarrisonHero() || !nullkiller2->isHeroLocked(h->getVisitedTown()->getGarrisonHero()))
|
||||
moveCreaturesToHero(h->getVisitedTown());
|
||||
|
||||
if(nullkiller->heroManager->getHeroRole(h) == HeroRole::MAIN && !h->hasSpellbook()
|
||||
&& nullkiller->getFreeGold() >= GameConstants::SPELLBOOK_GOLD_COST)
|
||||
if(nullkiller2->heroManager->getHeroRole(h) == HeroRole::MAIN && !h->hasSpellbook()
|
||||
&& nullkiller2->getFreeGold() >= GameConstants::SPELLBOOK_GOLD_COST)
|
||||
{
|
||||
if(h->getVisitedTown()->hasBuilt(BuildingID::MAGES_GUILD_1))
|
||||
cb->buyArtifact(h.get(), ArtifactID::SPELLBOOK);
|
||||
@@ -951,7 +951,7 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const
|
||||
|
||||
const CArmedInstance * armies[] = {destinationArmy, source};
|
||||
|
||||
auto bestArmy = nullkiller->armyManager->getBestArmy(destinationArmy, destinationArmy, source, myCb->getTile(source->visitablePos())->getTerrainID());
|
||||
auto bestArmy = nullkiller2->armyManager->getBestArmy(destinationArmy, destinationArmy, source, myCb->getTile(source->visitablePos())->getTerrainID());
|
||||
|
||||
for(auto army : armies)
|
||||
{
|
||||
@@ -1005,7 +1005,7 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const
|
||||
&& source->stacksCount() == 1
|
||||
&& (!destinationArmy->hasStackAtSlot(i) || destinationArmy->getCreature(i) == targetCreature))
|
||||
{
|
||||
auto weakest = nullkiller->armyManager->getBestUnitForScout(bestArmy, myCb->getTile(source->visitablePos())->getTerrainID());
|
||||
auto weakest = nullkiller2->armyManager->getBestUnitForScout(bestArmy, myCb->getTile(source->visitablePos())->getTerrainID());
|
||||
|
||||
if(weakest->creature == targetCreature)
|
||||
{
|
||||
@@ -1268,7 +1268,7 @@ void AIGateway::retrieveVisitableObjs()
|
||||
std::vector<const CGObjectInstance *> AIGateway::getFlaggedObjects() const
|
||||
{
|
||||
std::vector<const CGObjectInstance *> ret;
|
||||
for(const CGObjectInstance * obj : nullkiller->memory->visitableObjs)
|
||||
for(const CGObjectInstance * obj : nullkiller2->memory->visitableObjs)
|
||||
{
|
||||
if(obj->tempOwner == playerID)
|
||||
ret.push_back(obj);
|
||||
@@ -1281,11 +1281,11 @@ void AIGateway::addVisitableObj(const CGObjectInstance * obj)
|
||||
if(obj->ID == Obj::EVENT)
|
||||
return;
|
||||
|
||||
nullkiller->memory->addVisitableObject(obj);
|
||||
nullkiller2->memory->addVisitableObject(obj);
|
||||
|
||||
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
|
||||
{
|
||||
nullkiller->dangerHitMap->resetHitmap();
|
||||
nullkiller2->dangerHitMap->resetHitmap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1329,7 +1329,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
else
|
||||
{
|
||||
CGPath path;
|
||||
nullkiller->getPathsInfo(h.get())->getPath(path, dst);
|
||||
nullkiller2->getPathsInfo(h.get())->getPath(path, dst);
|
||||
if(path.nodes.empty())
|
||||
{
|
||||
logAi->error("Hero %s cannot reach %s.", h->getNameTranslated(), dst.toString());
|
||||
@@ -1379,7 +1379,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
{
|
||||
if(cb->getObj(exitId) && cb->getObj(exitId)->ID == Obj::WHIRLPOOL)
|
||||
{
|
||||
nullkiller->armyFormation->rearrangeArmyForWhirlpool(*h);
|
||||
nullkiller2->armyFormation->rearrangeArmyForWhirlpool(*h);
|
||||
}
|
||||
|
||||
destinationTeleport = exitId;
|
||||
@@ -1436,7 +1436,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
doTeleportMovement(destTeleportObj->id, nextCoord);
|
||||
if(teleportChannelProbingList.size())
|
||||
doChannelProbing();
|
||||
nullkiller->memory->markObjectVisited(destTeleportObj); //FIXME: Monoliths are not correctly visited
|
||||
nullkiller2->memory->markObjectVisited(destTeleportObj); //FIXME: Monoliths are not correctly visited
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -1612,7 +1612,7 @@ void AIGateway::buildArmyIn(const CGTownInstance * t)
|
||||
|
||||
void AIGateway::finish()
|
||||
{
|
||||
nullkiller->makingTurnInterrupption.interruptThread();
|
||||
nullkiller2->makingTurnInterrupption.interruptThread();
|
||||
|
||||
if (asyncTasks)
|
||||
{
|
||||
@@ -1638,7 +1638,7 @@ void AIGateway::executeActionAsync(const std::string & description, const std::f
|
||||
void AIGateway::lostHero(HeroPtr h)
|
||||
{
|
||||
logAi->debug("I lost my hero %s. It's best to forget and move on.", h.name());
|
||||
nullkiller->invalidatePathfinderData();
|
||||
nullkiller2->invalidatePathfinderData();
|
||||
}
|
||||
|
||||
void AIGateway::answerQuery(QueryID queryID, int selection)
|
||||
@@ -1681,7 +1681,7 @@ void AIGateway::validateObject(ObjectIdRef obj)
|
||||
{
|
||||
if(!obj)
|
||||
{
|
||||
nullkiller->memory->removeFromMemory(obj);
|
||||
nullkiller2->memory->removeFromMemory(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1770,7 +1770,7 @@ void AIStatus::waitTillFree()
|
||||
while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement)
|
||||
{
|
||||
cv.wait_for(lock, std::chrono::milliseconds(10));
|
||||
gateway->nullkiller->makingTurnInterrupption.interruptionPoint();
|
||||
gateway->nullkiller2->makingTurnInterrupption.interruptionPoint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1846,7 +1846,7 @@ bool AIStatus::channelProbing()
|
||||
|
||||
void AIGateway::invalidatePaths()
|
||||
{
|
||||
nullkiller->invalidatePaths();
|
||||
nullkiller2->invalidatePaths();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "../../lib/mapObjects/MiscObjects.h"
|
||||
#include "../../lib/spells/CSpellHandler.h"
|
||||
#include "Pathfinding/AIPathfinder.h"
|
||||
#include "Engine/Nullkiller.h"
|
||||
#include "Engine/Nullkiller2.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
class AsyncRunner;
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
public:
|
||||
ObjectInstanceID selectedObject;
|
||||
|
||||
std::unique_ptr<Nullkiller> nullkiller;
|
||||
std::unique_ptr<Nullkiller2> nullkiller2;
|
||||
|
||||
AIGateway();
|
||||
~AIGateway();
|
||||
|
||||
@@ -209,7 +209,7 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isObjectPassable(const Nullkiller * ai, const CGObjectInstance * obj)
|
||||
bool isObjectPassable(const Nullkiller2 * ai, const CGObjectInstance * obj)
|
||||
{
|
||||
return isObjectPassable(obj, ai->playerID, ai->cb->getPlayerRelations(obj->tempOwner, ai->playerID));
|
||||
}
|
||||
@@ -600,7 +600,7 @@ int64_t getArtifactScoreForHero(const CGHeroInstance * hero, const CArtifactInst
|
||||
return totalScore;
|
||||
}
|
||||
|
||||
bool isWeeklyRevisitable(const Nullkiller * ai, const CGObjectInstance * obj)
|
||||
bool isWeeklyRevisitable(const Nullkiller2 * ai, const CGObjectInstance * obj)
|
||||
{
|
||||
if(!obj)
|
||||
return false;
|
||||
@@ -644,7 +644,7 @@ int getDuplicatingSlots(const CArmedInstance * army)
|
||||
}
|
||||
|
||||
// todo: move to obj manager
|
||||
bool shouldVisit(const Nullkiller * ai, const CGHeroInstance * h, const CGObjectInstance * obj)
|
||||
bool shouldVisit(const Nullkiller2 * ai, const CGHeroInstance * h, const CGObjectInstance * obj)
|
||||
{
|
||||
auto relations = ai->cb->getPlayerRelations(obj->tempOwner, h->tempOwner);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace NKAI
|
||||
{
|
||||
struct creInfo;
|
||||
class AIGateway;
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
const int GOLD_MINE_PRODUCTION = 1000;
|
||||
const int WOOD_ORE_MINE_PRODUCTION = 2;
|
||||
@@ -201,11 +201,11 @@ void foreach_neighbour(CCallback * cbp, const int3 & pos, const Func & foo) // a
|
||||
}
|
||||
|
||||
bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater);
|
||||
bool isObjectPassable(const Nullkiller * ai, const CGObjectInstance * obj);
|
||||
bool isObjectPassable(const Nullkiller2 * ai, const CGObjectInstance * obj);
|
||||
bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations objectRelations);
|
||||
bool isBlockVisitObj(const int3 & pos);
|
||||
|
||||
bool isWeeklyRevisitable(const Nullkiller * ai, const CGObjectInstance * obj);
|
||||
bool isWeeklyRevisitable(const Nullkiller2 * ai, const CGObjectInstance * obj);
|
||||
|
||||
bool isObjectRemovable(const CGObjectInstance * obj); //FIXME FIXME: move logic to object property!
|
||||
bool isSafeToVisit(const CGHeroInstance * h, uint64_t dangerStrength, float safeAttackRatio);
|
||||
@@ -222,7 +222,7 @@ uint64_t getHeroArmyStrengthWithCommander(const CGHeroInstance * hero, const CCr
|
||||
uint64_t timeElapsed(std::chrono::time_point<std::chrono::high_resolution_clock> start);
|
||||
|
||||
// todo: move to obj manager
|
||||
bool shouldVisit(const Nullkiller * ai, const CGHeroInstance * h, const CGObjectInstance * obj);
|
||||
bool shouldVisit(const Nullkiller2 * ai, const CGHeroInstance * h, const CGObjectInstance * obj);
|
||||
int getDuplicatingSlots(const CArmedInstance * army);
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "ArmyManager.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/mapObjects/MapObjects.h"
|
||||
#include "../../../lib/mapping/TerrainTile.h"
|
||||
#include "../../../lib/IGameSettings.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
struct SlotInfo
|
||||
{
|
||||
@@ -83,11 +83,11 @@ class DLL_EXPORT ArmyManager : public IArmyManager
|
||||
{
|
||||
private:
|
||||
CPlayerSpecificInfoCallback * cb; //this is enough, but we downcast from CCallback
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
std::map<CreatureID, SlotInfo> totalArmy;
|
||||
|
||||
public:
|
||||
ArmyManager(CPlayerSpecificInfoCallback * CB, const Nullkiller * ai): cb(CB), ai(ai) {}
|
||||
ArmyManager(CPlayerSpecificInfoCallback * CB, const Nullkiller2 * ai): cb(CB), ai(ai) {}
|
||||
void update() override;
|
||||
|
||||
ui64 howManyReinforcementsCanBuy(const CCreatureSet * target, const CGDwelling * source) const override;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*
|
||||
*/
|
||||
#include "../StdInc.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/entities/building/CBuilding.h"
|
||||
#include "../../../lib/IGameSettings.h"
|
||||
|
||||
@@ -405,7 +405,7 @@ BuildingInfo::BuildingInfo(
|
||||
const CCreature * creature,
|
||||
CreatureID baseCreature,
|
||||
const CGTownInstance * town,
|
||||
Nullkiller * ai)
|
||||
Nullkiller2 * ai)
|
||||
{
|
||||
id = building->bid;
|
||||
buildCost = building->resources;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
class DLL_EXPORT BuildingInfo
|
||||
{
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
const CCreature * creature,
|
||||
CreatureID baseCreature,
|
||||
const CGTownInstance * town,
|
||||
Nullkiller * ai);
|
||||
Nullkiller2 * ai);
|
||||
|
||||
std::string toString() const;
|
||||
};
|
||||
@@ -85,10 +85,10 @@ private:
|
||||
TResources armyCost;
|
||||
TResources dailyIncome;
|
||||
float goldPressure;
|
||||
Nullkiller * ai;
|
||||
Nullkiller2 * ai;
|
||||
|
||||
public:
|
||||
BuildAnalyzer(Nullkiller * ai) : ai(ai) {}
|
||||
BuildAnalyzer(Nullkiller2 * ai) : ai(ai) {}
|
||||
void update();
|
||||
|
||||
TResources getResourcesRequiredNow() const;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "../StdInc.h"
|
||||
#include "DangerHitMapAnalyzer.h"
|
||||
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../pforeach.h"
|
||||
#include "../../../lib/callback/GameRandomizer.h"
|
||||
#include "../../../lib/logging/VisualLogger.h"
|
||||
@@ -140,7 +140,12 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
newThreat.hero = path.targetHero;
|
||||
newThreat.turn = path.turn();
|
||||
newThreat.threat = path.getHeroStrength() * (1 - path.movementCost() / 2.0);
|
||||
// Why is this danger calculated so differently than FuzzyHelper::evaluateDanger?
|
||||
// shouldn't it use the path danger instead of hero strength?
|
||||
newThreat.danger = path.getHeroStrength();
|
||||
auto danger2 = ai->dangerEvaluator->evaluateDanger(pos, path.targetHero);
|
||||
logAi->trace("Danger comparison for (%d %d %d) %s is %f vs %f",
|
||||
pos.x, pos.y, pos.z, path.targetHero->getNameTranslated(), newThreat.danger, danger2);
|
||||
|
||||
if(newThreat.value() > node.maximumDanger.value())
|
||||
{
|
||||
|
||||
@@ -75,11 +75,11 @@ private:
|
||||
tbb::concurrent_vector<EnemyHeroAccessibleObject> enemyHeroAccessibleObjects;
|
||||
bool hitMapUpToDate = false;
|
||||
bool tileOwnersUpToDate = false;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
std::map<ObjectInstanceID, std::vector<HitMapInfo>> townThreats;
|
||||
|
||||
public:
|
||||
DangerHitMapAnalyzer(const Nullkiller * ai) :ai(ai) {}
|
||||
DangerHitMapAnalyzer(const Nullkiller2 * ai) :ai(ai) {}
|
||||
|
||||
void updateHitMap();
|
||||
void calculateTileOwners();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "../StdInc.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/mapObjects/MapObjects.h"
|
||||
#include "../../../lib/IGameSettings.h"
|
||||
#include "../../../lib/spells/ISpellMechanics.h"
|
||||
|
||||
@@ -43,12 +43,12 @@ private:
|
||||
static const SecondarySkillEvaluator scountSkillsScores;
|
||||
|
||||
CCallback * cb; //this is enough, but we downcast from CCallback
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
std::map<HeroPtr, HeroRole> heroRoles;
|
||||
std::map<ObjectInstanceID, float> knownFightingStrength;
|
||||
|
||||
public:
|
||||
HeroManager(CCallback * CB, const Nullkiller * ai) : cb(CB), ai(ai) {}
|
||||
HeroManager(CCallback * CB, const Nullkiller2 * ai) : cb(CB), ai(ai) {}
|
||||
const std::map<HeroPtr, HeroRole> & getHeroRoles() const;
|
||||
HeroRole getHeroRole(const HeroPtr & hero) const;
|
||||
int selectBestSkill(const HeroPtr & hero, const std::vector<SecondarySkill> & skills) const;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "ObjectClusterizer.h"
|
||||
#include "../Goals/ExecuteHeroChain.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
ObjectCluster nearObjects;
|
||||
ObjectCluster farObjects;
|
||||
ClusterMap blockedObjects;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
RewardEvaluator valueEvaluator;
|
||||
bool isUpToDate;
|
||||
std::vector<ObjectInstanceID> invalidated;
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
const CGObjectInstance * getBlocker(const AIPath & path) const;
|
||||
std::optional<const CGObjectInstance *> getBlocker(const AIPathNodeInfo & node) const;
|
||||
|
||||
ObjectClusterizer(const Nullkiller * ai): ai(ai), valueEvaluator(ai), isUpToDate(false){}
|
||||
ObjectClusterizer(const Nullkiller2 * ai): ai(ai), valueEvaluator(ai), isUpToDate(false){}
|
||||
|
||||
void validateObjects();
|
||||
void onObjectRemoved(ObjectInstanceID id);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "../Goals/Composition.h"
|
||||
#include "../Goals/BuildThis.h"
|
||||
#include "../Goals/SaveResources.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
@@ -27,7 +27,7 @@ std::string BuildingBehavior::toString() const
|
||||
return "Build";
|
||||
}
|
||||
|
||||
Goals::TGoalVec BuildingBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec BuildingBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
Goals::TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
Goals::TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
bool operator==(const BuildingBehavior & other) const override
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "../AIGateway.h"
|
||||
#include "../AIUtility.h"
|
||||
#include "../Goals/BuyArmy.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
@@ -24,7 +24,7 @@ std::string BuyArmyBehavior::toString() const
|
||||
return "Buy army";
|
||||
}
|
||||
|
||||
Goals::TGoalVec BuyArmyBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec BuyArmyBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Goals
|
||||
class BuyArmyBehavior : public CGoal<BuyArmyBehavior>
|
||||
{
|
||||
public:
|
||||
Goals::TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
Goals::TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
bool operator==(const BuyArmyBehavior & other) const override
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../Goals/Composition.h"
|
||||
#include "../Goals/ExecuteHeroChain.h"
|
||||
#include "../Goals/Invalid.h"
|
||||
@@ -49,7 +49,7 @@ bool CaptureObjectsBehavior::operator==(const CaptureObjectsBehavior & other) co
|
||||
|
||||
Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
|
||||
const std::vector<AIPath> & paths,
|
||||
const Nullkiller * nullkiller,
|
||||
const Nullkiller2 * nullkiller,
|
||||
const CGObjectInstance * objToVisit,
|
||||
bool force)
|
||||
{
|
||||
@@ -169,7 +169,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
|
||||
void CaptureObjectsBehavior::decomposeObjects(
|
||||
Goals::TGoalVec & result,
|
||||
const std::vector<const CGObjectInstance *> & objs,
|
||||
const Nullkiller * nullkiller) const
|
||||
const Nullkiller2 * nullkiller) const
|
||||
{
|
||||
if(objs.empty())
|
||||
{
|
||||
@@ -212,7 +212,7 @@ void CaptureObjectsBehavior::decomposeObjects(
|
||||
});
|
||||
}
|
||||
|
||||
Goals::TGoalVec CaptureObjectsBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec CaptureObjectsBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Goals
|
||||
specificObjects = true;
|
||||
}
|
||||
|
||||
Goals::TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
Goals::TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
CaptureObjectsBehavior & ofType(int type)
|
||||
@@ -70,7 +70,7 @@ namespace Goals
|
||||
|
||||
static Goals::TGoalVec getVisitGoals(
|
||||
const std::vector<AIPath> & paths,
|
||||
const Nullkiller * nullkiller,
|
||||
const Nullkiller2 * nullkiller,
|
||||
const CGObjectInstance * objToVisit = nullptr,
|
||||
bool force = false);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Goals
|
||||
void decomposeObjects(
|
||||
Goals::TGoalVec & result,
|
||||
const std::vector<const CGObjectInstance *> & objs,
|
||||
const Nullkiller * nullkiller) const;
|
||||
const Nullkiller2 * nullkiller) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "ClusterBehavior.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
#include "../Markers/UnlockCluster.h"
|
||||
#include "../Goals/Composition.h"
|
||||
@@ -26,7 +26,7 @@ std::string ClusterBehavior::toString() const
|
||||
return "Unlock Clusters";
|
||||
}
|
||||
|
||||
Goals::TGoalVec ClusterBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec ClusterBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
auto clusters = ai->objectClusterizer->getLockedClusters();
|
||||
@@ -39,7 +39,7 @@ Goals::TGoalVec ClusterBehavior::decompose(const Nullkiller * ai) const
|
||||
return tasks;
|
||||
}
|
||||
|
||||
Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * ai, std::shared_ptr<ObjectCluster> cluster) const
|
||||
Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller2 * ai, std::shared_ptr<ObjectCluster> cluster) const
|
||||
{
|
||||
auto center = cluster->calculateCenter(ai->cb.get());
|
||||
auto paths = ai->pathfinder->getPathInfo(center->visitablePos(), ai->isObjectGraphAllowed());
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
bool operator==(const ClusterBehavior & other) const override
|
||||
@@ -37,7 +37,7 @@ namespace Goals
|
||||
}
|
||||
|
||||
private:
|
||||
Goals::TGoalVec decomposeCluster(const Nullkiller * ai, std::shared_ptr<ObjectCluster> cluster) const;
|
||||
Goals::TGoalVec decomposeCluster(const Nullkiller2 * ai, std::shared_ptr<ObjectCluster> cluster) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "DefenceBehavior.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
#include "../Goals/BuyArmy.h"
|
||||
#include "../Goals/ExecuteHeroChain.h"
|
||||
@@ -34,7 +34,7 @@ std::string DefenceBehavior::toString() const
|
||||
return "Defend towns";
|
||||
}
|
||||
|
||||
Goals::TGoalVec DefenceBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec DefenceBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
|
||||
@@ -46,7 +46,7 @@ Goals::TGoalVec DefenceBehavior::decompose(const Nullkiller * ai) const
|
||||
return tasks;
|
||||
}
|
||||
|
||||
bool isThreatUnderControl(const CGTownInstance * town, const HitMapInfo & threat, const Nullkiller * ai, const std::vector<AIPath> & paths)
|
||||
bool isThreatUnderControl(const CGTownInstance * town, const HitMapInfo & threat, const Nullkiller2 * ai, const std::vector<AIPath> & paths)
|
||||
{
|
||||
int dayOfWeek = ai->cb->getDate(Date::DAY_OF_WEEK);
|
||||
|
||||
@@ -81,7 +81,7 @@ void handleCounterAttack(
|
||||
const CGTownInstance * town,
|
||||
const HitMapInfo & threat,
|
||||
const HitMapInfo & maximumDanger,
|
||||
const Nullkiller * ai,
|
||||
const Nullkiller2 * ai,
|
||||
Goals::TGoalVec & tasks)
|
||||
{
|
||||
if(threat.hero.validAndSet()
|
||||
@@ -107,7 +107,7 @@ void handleCounterAttack(
|
||||
}
|
||||
}
|
||||
|
||||
bool handleGarrisonHeroFromPreviousTurn(const CGTownInstance * town, Goals::TGoalVec & tasks, const Nullkiller * ai)
|
||||
bool handleGarrisonHeroFromPreviousTurn(const CGTownInstance * town, Goals::TGoalVec & tasks, const Nullkiller2 * ai)
|
||||
{
|
||||
if(ai->isHeroLocked(town->getGarrisonHero()))
|
||||
{
|
||||
@@ -149,7 +149,7 @@ bool handleGarrisonHeroFromPreviousTurn(const CGTownInstance * town, Goals::TGoa
|
||||
return false;
|
||||
}
|
||||
|
||||
void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller * ai) const
|
||||
void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller2 * ai) const
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Evaluating defence for %s", town->getNameTranslated());
|
||||
@@ -423,7 +423,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
logAi->debug("Found %d tasks", tasks.size());
|
||||
}
|
||||
|
||||
void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & threat, const CGTownInstance * town, const Nullkiller * ai) const
|
||||
void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & threat, const CGTownInstance * town, const Nullkiller2 * ai) const
|
||||
{
|
||||
if (threat.turn > 0 || town->getGarrisonHero() || town->getVisitingHero())
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
Goals::TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
Goals::TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
bool operator==(const DefenceBehavior & other) const override
|
||||
@@ -37,8 +37,8 @@ namespace Goals
|
||||
}
|
||||
|
||||
private:
|
||||
void evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller * ai) const;
|
||||
void evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & threat, const CGTownInstance * town, const Nullkiller * ai) const;
|
||||
void evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller2 * ai) const;
|
||||
void evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & threat, const CGTownInstance * town, const Nullkiller2 * ai) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ std::string ExplorationBehavior::toString() const
|
||||
return "Explore";
|
||||
}
|
||||
|
||||
Goals::TGoalVec ExplorationBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec ExplorationBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
bool operator==(const ExplorationBehavior & other) const override
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../Goals/ExecuteHeroChain.h"
|
||||
#include "../Goals/Composition.h"
|
||||
#include "../Goals/RecruitHero.h"
|
||||
@@ -30,7 +30,7 @@ std::string GatherArmyBehavior::toString() const
|
||||
return "Gather army";
|
||||
}
|
||||
|
||||
Goals::TGoalVec GatherArmyBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec GatherArmyBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
|
||||
@@ -59,7 +59,7 @@ Goals::TGoalVec GatherArmyBehavior::decompose(const Nullkiller * ai) const
|
||||
return tasks;
|
||||
}
|
||||
|
||||
Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * ai, const CGHeroInstance * hero) const
|
||||
Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller2 * ai, const CGHeroInstance * hero) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
const int3 pos = hero->visitablePos();
|
||||
@@ -216,7 +216,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * ai, con
|
||||
return tasks;
|
||||
}
|
||||
|
||||
Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * ai, const CGTownInstance * upgrader) const
|
||||
Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller2 * ai, const CGTownInstance * upgrader) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
const int3 pos = upgrader->visitablePos();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
bool operator==(const GatherArmyBehavior & other) const override
|
||||
@@ -34,8 +34,8 @@ namespace Goals
|
||||
}
|
||||
|
||||
private:
|
||||
TGoalVec deliverArmyToHero(const Nullkiller * ai, const CGHeroInstance * hero) const;
|
||||
TGoalVec upgradeArmy(const Nullkiller * ai, const CGTownInstance * upgrader) const;
|
||||
TGoalVec deliverArmyToHero(const Nullkiller2 * ai, const CGHeroInstance * hero) const;
|
||||
TGoalVec upgradeArmy(const Nullkiller2 * ai, const CGTownInstance * upgrader) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ std::string RecruitHeroBehavior::toString() const
|
||||
return "Recruit hero";
|
||||
}
|
||||
|
||||
Goals::TGoalVec RecruitHeroBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec RecruitHeroBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
auto towns = ai->cb->getTownsInfo();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
bool operator==(const RecruitHeroBehavior & other) const override
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "../Goals/ExecuteHeroChain.h"
|
||||
#include "../Goals/ExchangeSwapTownHeroes.h"
|
||||
#include "../../../lib/mapObjects/CGResource.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
@@ -41,7 +41,7 @@ const AIPath getShortestPath(const CGTownInstance * town, const std::vector<AIPa
|
||||
return shortestPath;
|
||||
}
|
||||
|
||||
const CGHeroInstance * getNearestHero(const Nullkiller * ai, const CGTownInstance * town)
|
||||
const CGHeroInstance * getNearestHero(const Nullkiller2 * ai, const CGTownInstance * town)
|
||||
{
|
||||
auto paths = ai->pathfinder->getPathInfo(town->visitablePos());
|
||||
|
||||
@@ -59,7 +59,7 @@ const CGHeroInstance * getNearestHero(const Nullkiller * ai, const CGTownInstanc
|
||||
return shortestPath.targetHero;
|
||||
}
|
||||
|
||||
bool needToRecruitHero(const Nullkiller * ai, const CGTownInstance * startupTown)
|
||||
bool needToRecruitHero(const Nullkiller2 * ai, const CGTownInstance * startupTown)
|
||||
{
|
||||
if(!ai->heroManager->canRecruitHero(startupTown))
|
||||
return false;
|
||||
@@ -108,7 +108,7 @@ bool needToRecruitHero(const Nullkiller * ai, const CGTownInstance * startupTown
|
||||
return cb->getHeroCount(ai->playerID, true) < basicCount + boost;
|
||||
}
|
||||
|
||||
Goals::TGoalVec StartupBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec StartupBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
auto towns = ai->cb->getTownsInfo();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
bool operator==(const StartupBehavior & other) const override
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "../Goals/Composition.h"
|
||||
#include "../Goals/ExecuteHeroChain.h"
|
||||
#include "lib/mapObjects/MapObjects.h" //for victory conditions
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
@@ -27,7 +27,7 @@ std::string StayAtTownBehavior::toString() const
|
||||
return "StayAtTownBehavior";
|
||||
}
|
||||
|
||||
Goals::TGoalVec StayAtTownBehavior::decompose(const Nullkiller * ai) const
|
||||
Goals::TGoalVec StayAtTownBehavior::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
Goals::TGoalVec tasks;
|
||||
auto towns = ai->cb->getTownsInfo();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
bool operator==(const StayAtTownBehavior & other) const override
|
||||
|
||||
@@ -47,7 +47,7 @@ set(Nullkiller_SRCS
|
||||
Markers/UnlockCluster.cpp
|
||||
Markers/DefendTown.cpp
|
||||
Markers/ExplorationPoint.cpp
|
||||
Engine/Nullkiller.cpp
|
||||
Engine/Nullkiller2.cpp
|
||||
Engine/DeepDecomposer.cpp
|
||||
Engine/PriorityEvaluator.cpp
|
||||
Analyzers/DangerHitMapAnalyzer.cpp
|
||||
@@ -123,7 +123,7 @@ set(Nullkiller_HEADERS
|
||||
Markers/UnlockCluster.h
|
||||
Markers/DefendTown.h
|
||||
Markers/ExplorationPoint.h
|
||||
Engine/Nullkiller.h
|
||||
Engine/Nullkiller2.h
|
||||
Engine/DeepDecomposer.h
|
||||
Engine/PriorityEvaluator.h
|
||||
Analyzers/DangerHitMapAnalyzer.h
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace NKAI
|
||||
|
||||
using namespace Goals;
|
||||
|
||||
DeepDecomposer::DeepDecomposer(const Nullkiller * ai)
|
||||
DeepDecomposer::DeepDecomposer(const Nullkiller2 * ai)
|
||||
:ai(ai), depth(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ private:
|
||||
std::vector<Goals::TGoalVec> goals;
|
||||
std::vector<TGoalHashSet> decompositionCache;
|
||||
int depth;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
|
||||
public:
|
||||
DeepDecomposer(const Nullkiller * ai);
|
||||
DeepDecomposer(const Nullkiller2 * ai);
|
||||
void reset();
|
||||
void decompose(Goals::TGoalVec & result, Goals::TSubgoal behavior, int depthLimit);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "FuzzyHelper.h"
|
||||
|
||||
#include "../Goals/Goals.h"
|
||||
#include "Nullkiller.h"
|
||||
#include "Nullkiller2.h"
|
||||
|
||||
#include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
||||
#include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
class DLL_EXPORT FuzzyHelper
|
||||
{
|
||||
private:
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
TacticalAdvantageEngine tacticalAdvantageEngine;
|
||||
|
||||
public:
|
||||
FuzzyHelper(const Nullkiller * ai): ai(ai) {}
|
||||
FuzzyHelper(const Nullkiller2 * ai): ai(ai) {}
|
||||
|
||||
ui64 evaluateDanger(const CGObjectInstance * obj);
|
||||
ui64 evaluateDanger(const int3 & tile, const CGHeroInstance * visitor, bool checkGuards = true);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "Nullkiller.h"
|
||||
#include "Nullkiller2.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Behaviors/CaptureObjectsBehavior.h"
|
||||
#include "../Behaviors/RecruitHeroBehavior.h"
|
||||
@@ -33,9 +33,9 @@ namespace NKAI
|
||||
using namespace Goals;
|
||||
|
||||
// while we play vcmieagles graph can be shared
|
||||
std::unique_ptr<ObjectGraph> Nullkiller::baseGraph;
|
||||
std::unique_ptr<ObjectGraph> Nullkiller2::baseGraph;
|
||||
|
||||
Nullkiller::Nullkiller()
|
||||
Nullkiller2::Nullkiller2()
|
||||
: activeHero(nullptr)
|
||||
, scanDepth(ScanDepth::MAIN_FULL)
|
||||
, useHeroChain(true)
|
||||
@@ -45,7 +45,7 @@ Nullkiller::Nullkiller()
|
||||
|
||||
}
|
||||
|
||||
Nullkiller::~Nullkiller() = default;
|
||||
Nullkiller2::~Nullkiller2() = default;
|
||||
|
||||
bool canUseOpenMap(std::shared_ptr<CCallback> cb, PlayerColor playerID)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ bool canUseOpenMap(std::shared_ptr<CCallback> cb, PlayerColor playerID)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Nullkiller::init(std::shared_ptr<CCallback> cb, AIGateway * gateway)
|
||||
void Nullkiller2::init(std::shared_ptr<CCallback> cb, AIGateway * gateway)
|
||||
{
|
||||
this->cb = cb;
|
||||
this->gateway = gateway;
|
||||
@@ -166,7 +166,7 @@ void TaskPlan::merge(TSubgoal task)
|
||||
tasks.emplace_back(task);
|
||||
}
|
||||
|
||||
Goals::TTask Nullkiller::choseBestTask(Goals::TGoalVec & tasks) const
|
||||
Goals::TTask Nullkiller2::choseBestTask(Goals::TGoalVec & tasks) const
|
||||
{
|
||||
if(tasks.empty())
|
||||
{
|
||||
@@ -187,7 +187,7 @@ Goals::TTask Nullkiller::choseBestTask(Goals::TGoalVec & tasks) const
|
||||
return taskptr(*bestTask);
|
||||
}
|
||||
|
||||
Goals::TTaskVec Nullkiller::buildPlan(TGoalVec & tasks, int priorityTier) const
|
||||
Goals::TTaskVec Nullkiller2::buildPlan(TGoalVec & tasks, int priorityTier) const
|
||||
{
|
||||
TaskPlan taskPlan;
|
||||
|
||||
@@ -216,7 +216,7 @@ Goals::TTaskVec Nullkiller::buildPlan(TGoalVec & tasks, int priorityTier) const
|
||||
return taskPlan.getTasks();
|
||||
}
|
||||
|
||||
void Nullkiller::decompose(Goals::TGoalVec & result, Goals::TSubgoal behavior, int decompositionMaxDepth) const
|
||||
void Nullkiller2::decompose(Goals::TGoalVec & result, Goals::TSubgoal behavior, int decompositionMaxDepth) const
|
||||
{
|
||||
makingTurnInterrupption.interruptionPoint();
|
||||
|
||||
@@ -234,7 +234,7 @@ void Nullkiller::decompose(Goals::TGoalVec & result, Goals::TSubgoal behavior, i
|
||||
timeElapsed(start));
|
||||
}
|
||||
|
||||
void Nullkiller::resetAiState()
|
||||
void Nullkiller2::resetAiState()
|
||||
{
|
||||
std::unique_lock lockGuard(aiStateMutex);
|
||||
|
||||
@@ -252,12 +252,12 @@ void Nullkiller::resetAiState()
|
||||
}
|
||||
}
|
||||
|
||||
void Nullkiller::invalidatePathfinderData()
|
||||
void Nullkiller2::invalidatePathfinderData()
|
||||
{
|
||||
pathfinderInvalidated = true;
|
||||
}
|
||||
|
||||
void Nullkiller::updateAiState(int pass, bool fast)
|
||||
void Nullkiller2::updateAiState(int pass, bool fast)
|
||||
{
|
||||
makingTurnInterrupption.interruptionPoint();
|
||||
|
||||
@@ -334,12 +334,12 @@ void Nullkiller::updateAiState(int pass, bool fast)
|
||||
logAi->debug("AI state updated in %ld ms", timeElapsed(start));
|
||||
}
|
||||
|
||||
bool Nullkiller::isHeroLocked(const CGHeroInstance * hero) const
|
||||
bool Nullkiller2::isHeroLocked(const CGHeroInstance * hero) const
|
||||
{
|
||||
return getHeroLockedReason(hero) != HeroLockedReason::NOT_LOCKED;
|
||||
}
|
||||
|
||||
bool Nullkiller::arePathHeroesLocked(const AIPath & path) const
|
||||
bool Nullkiller2::arePathHeroesLocked(const AIPath & path) const
|
||||
{
|
||||
if(getHeroLockedReason(path.targetHero) == HeroLockedReason::STARTUP)
|
||||
{
|
||||
@@ -365,14 +365,14 @@ bool Nullkiller::arePathHeroesLocked(const AIPath & path) const
|
||||
return false;
|
||||
}
|
||||
|
||||
HeroLockedReason Nullkiller::getHeroLockedReason(const CGHeroInstance * hero) const
|
||||
HeroLockedReason Nullkiller2::getHeroLockedReason(const CGHeroInstance * hero) const
|
||||
{
|
||||
auto found = lockedHeroes.find(hero);
|
||||
|
||||
return found != lockedHeroes.end() ? found->second : HeroLockedReason::NOT_LOCKED;
|
||||
}
|
||||
|
||||
void Nullkiller::makeTurn()
|
||||
void Nullkiller2::makeTurn()
|
||||
{
|
||||
std::lock_guard<std::mutex> sharedStorageLock(AISharedStorage::locker);
|
||||
|
||||
@@ -572,7 +572,7 @@ void Nullkiller::makeTurn()
|
||||
}
|
||||
}
|
||||
|
||||
bool Nullkiller::areAffectedObjectsPresent(Goals::TTask task) const
|
||||
bool Nullkiller2::areAffectedObjectsPresent(Goals::TTask task) const
|
||||
{
|
||||
auto affectedObjs = task->getAffectedObjects();
|
||||
|
||||
@@ -585,7 +585,7 @@ bool Nullkiller::areAffectedObjectsPresent(Goals::TTask task) const
|
||||
return true;
|
||||
}
|
||||
|
||||
HeroRole Nullkiller::getTaskRole(Goals::TTask task) const
|
||||
HeroRole Nullkiller2::getTaskRole(Goals::TTask task) const
|
||||
{
|
||||
HeroPtr hero = task->getHero();
|
||||
HeroRole heroRole = HeroRole::MAIN;
|
||||
@@ -596,7 +596,7 @@ HeroRole Nullkiller::getTaskRole(Goals::TTask task) const
|
||||
return heroRole;
|
||||
}
|
||||
|
||||
bool Nullkiller::executeTask(Goals::TTask task)
|
||||
bool Nullkiller2::executeTask(Goals::TTask task)
|
||||
{
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
std::string taskDescr = task->toString();
|
||||
@@ -624,7 +624,7 @@ bool Nullkiller::executeTask(Goals::TTask task)
|
||||
return true;
|
||||
}
|
||||
|
||||
TResources Nullkiller::getFreeResources() const
|
||||
TResources Nullkiller2::getFreeResources() const
|
||||
{
|
||||
auto freeRes = cb->getResourceAmount() - lockedResources;
|
||||
|
||||
@@ -633,12 +633,12 @@ TResources Nullkiller::getFreeResources() const
|
||||
return freeRes;
|
||||
}
|
||||
|
||||
void Nullkiller::lockResources(const TResources & res)
|
||||
void Nullkiller2::lockResources(const TResources & res)
|
||||
{
|
||||
lockedResources += res;
|
||||
}
|
||||
|
||||
bool Nullkiller::handleTrading()
|
||||
bool Nullkiller2::handleTrading()
|
||||
{
|
||||
bool haveTraded = false;
|
||||
bool shouldTryToTrade = true;
|
||||
@@ -736,12 +736,12 @@ bool Nullkiller::handleTrading()
|
||||
return haveTraded;
|
||||
}
|
||||
|
||||
std::shared_ptr<const CPathsInfo> Nullkiller::getPathsInfo(const CGHeroInstance * h) const
|
||||
std::shared_ptr<const CPathsInfo> Nullkiller2::getPathsInfo(const CGHeroInstance * h) const
|
||||
{
|
||||
return pathfinderCache->getPathsInfo(h);
|
||||
}
|
||||
|
||||
void Nullkiller::invalidatePaths()
|
||||
void Nullkiller2::invalidatePaths()
|
||||
{
|
||||
pathfinderCache->invalidatePaths();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
void merge(Goals::TSubgoal task);
|
||||
};
|
||||
|
||||
class Nullkiller
|
||||
class Nullkiller2
|
||||
{
|
||||
private:
|
||||
const CGHeroInstance * activeHero;
|
||||
@@ -110,8 +110,8 @@ public:
|
||||
std::mutex aiStateMutex;
|
||||
mutable ThreadInterruption makingTurnInterrupption;
|
||||
|
||||
Nullkiller();
|
||||
~Nullkiller();
|
||||
Nullkiller2();
|
||||
~Nullkiller2();
|
||||
void init(std::shared_ptr<CCallback> cb, AIGateway * gateway);
|
||||
void makeTurn();
|
||||
bool isActive(const CGHeroInstance * hero) const { return activeHero == hero; }
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include <limits>
|
||||
|
||||
#include "Nullkiller.h"
|
||||
#include "Nullkiller2.h"
|
||||
#include "../../../lib/entities/artifact/CArtifact.h"
|
||||
#include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
||||
#include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
||||
@@ -37,7 +37,7 @@ namespace NKAI
|
||||
|
||||
constexpr float MIN_CRITICAL_VALUE = 2.0f;
|
||||
|
||||
EvaluationContext::EvaluationContext(const Nullkiller* ai)
|
||||
EvaluationContext::EvaluationContext(const Nullkiller2* ai)
|
||||
: movementCost(0.0),
|
||||
manaCost(0),
|
||||
danger(0),
|
||||
@@ -93,7 +93,7 @@ void PriorityEvaluator::initVisitTile()
|
||||
turnVariable = engine->getInputVariable("turn");
|
||||
mainTurnDistanceVariable = engine->getInputVariable("mainTurnDistance");
|
||||
scoutTurnDistanceVariable = engine->getInputVariable("scoutTurnDistance");
|
||||
goldRewardVariable = engine->getInputVariable("goldReward");
|
||||
goldRewardVsMovementVariable = engine->getInputVariable("goldReward");
|
||||
armyRewardVariable = engine->getInputVariable("armyReward");
|
||||
skillRewardVariable = engine->getInputVariable("skillReward");
|
||||
rewardTypeVariable = engine->getInputVariable("rewardType");
|
||||
@@ -377,6 +377,11 @@ float RewardEvaluator::getEnemyHeroStrategicalValue(const CGHeroInstance * enemy
|
||||
return std::min(1.5f, objectValue * 0.9f + (1.5f - (1.5f / (1 + enemy->level))));
|
||||
}
|
||||
|
||||
/**
|
||||
* getNowResourceRequirementStrength
|
||||
* @param resType
|
||||
* @return between 0-1.0f
|
||||
*/
|
||||
float RewardEvaluator::getResourceRequirementStrength(GameResID resType) const
|
||||
{
|
||||
TResources requiredResources = ai->buildAnalyzer->getResourcesRequiredNow();
|
||||
@@ -388,11 +393,14 @@ float RewardEvaluator::getResourceRequirementStrength(GameResID resType) const
|
||||
if(dailyIncome[resType] == 0)
|
||||
return 1.0f;
|
||||
|
||||
float ratio = (float)requiredResources[resType] / dailyIncome[resType] / 2;
|
||||
|
||||
return std::min(ratio, 1.0f);
|
||||
return 0.95f;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param resType
|
||||
* @return between 0-1.0f
|
||||
*/
|
||||
float RewardEvaluator::getTotalResourceRequirementStrength(GameResID resType) const
|
||||
{
|
||||
TResources requiredResources = ai->buildAnalyzer->getTotalResourcesRequired();
|
||||
@@ -401,11 +409,10 @@ float RewardEvaluator::getTotalResourceRequirementStrength(GameResID resType) co
|
||||
if(requiredResources[resType] == 0)
|
||||
return 0;
|
||||
|
||||
float ratio = dailyIncome[resType] == 0
|
||||
? (float)requiredResources[resType] / 10.0f
|
||||
: (float)requiredResources[resType] / dailyIncome[resType] / 20.0f;
|
||||
if(dailyIncome[resType] == 0)
|
||||
return 1.0f;
|
||||
|
||||
return std::min(ratio, 2.0f);
|
||||
return 0.95f;
|
||||
}
|
||||
|
||||
uint64_t RewardEvaluator::townArmyGrowth(const CGTownInstance * town) const
|
||||
@@ -429,18 +436,22 @@ float RewardEvaluator::getManaRecoveryArmyReward(const CGHeroInstance * hero) co
|
||||
return ai->heroManager->getMagicStrength(hero) * 10000 * (1.0f - std::sqrt(static_cast<float>(hero->mana) / hero->manaLimit()));
|
||||
}
|
||||
|
||||
/**
|
||||
* getCombinedResourceRequirementStrength
|
||||
* @param res
|
||||
* @return between 0-1.0f
|
||||
*/
|
||||
float RewardEvaluator::getResourceRequirementStrength(const TResources & res) const
|
||||
{
|
||||
float sum = 0.0f;
|
||||
|
||||
for(TResources::nziterator it(res); it.valid(); it++)
|
||||
{
|
||||
//Evaluate resources used for construction. Gold is evaluated separately.
|
||||
if(it->resType != EGameResID::GOLD)
|
||||
{
|
||||
sum += 0.1f * it->resVal * getResourceRequirementStrength(it->resType)
|
||||
+ 0.05f * it->resVal * getTotalResourceRequirementStrength(it->resType);
|
||||
}
|
||||
auto calculation = 0.6f * getResourceRequirementStrength(it->resType)
|
||||
+ 0.4f * getTotalResourceRequirementStrength(it->resType);
|
||||
|
||||
// Even not required resources should be valuable because they shouldn't be left for the enemies to collect
|
||||
sum += std::min(0.5f, calculation);
|
||||
}
|
||||
|
||||
return sum;
|
||||
@@ -456,9 +467,11 @@ float RewardEvaluator::getStrategicalValue(const CGObjectInstance * target, cons
|
||||
case Obj::MINE:
|
||||
{
|
||||
auto mine = dynamic_cast<const CGMine *>(target);
|
||||
return mine->producedResource == EGameResID::GOLD
|
||||
? 0.5f
|
||||
: 0.4f * getTotalResourceRequirementStrength(mine->producedResource) + 0.1f * getResourceRequirementStrength(mine->producedResource);
|
||||
TResources res;
|
||||
res[mine->producedResource] = mine->producedQuantity;
|
||||
|
||||
// Mines should have higher priority than resources
|
||||
return 1.0f + getResourceRequirementStrength(res);
|
||||
}
|
||||
|
||||
case Obj::RESOURCE:
|
||||
@@ -466,7 +479,7 @@ float RewardEvaluator::getStrategicalValue(const CGObjectInstance * target, cons
|
||||
auto resource = dynamic_cast<const CGResource *>(target);
|
||||
TResources res;
|
||||
res[resource->resourceID()] = resource->getAmount();
|
||||
|
||||
|
||||
return getResourceRequirementStrength(res);
|
||||
}
|
||||
|
||||
@@ -925,10 +938,10 @@ public:
|
||||
class ExecuteHeroChainEvaluationContextBuilder : public IEvaluationContextBuilder
|
||||
{
|
||||
private:
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
|
||||
public:
|
||||
ExecuteHeroChainEvaluationContextBuilder(const Nullkiller * ai) : ai(ai) {}
|
||||
ExecuteHeroChainEvaluationContextBuilder(const Nullkiller2 * ai) : ai(ai) {}
|
||||
|
||||
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
|
||||
{
|
||||
@@ -1044,7 +1057,7 @@ public:
|
||||
class ClusterEvaluationContextBuilder : public IEvaluationContextBuilder
|
||||
{
|
||||
public:
|
||||
ClusterEvaluationContextBuilder(const Nullkiller * ai) {}
|
||||
ClusterEvaluationContextBuilder(const Nullkiller2 * ai) {}
|
||||
|
||||
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
|
||||
{
|
||||
@@ -1128,10 +1141,10 @@ public:
|
||||
class DismissHeroContextBuilder : public IEvaluationContextBuilder
|
||||
{
|
||||
private:
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
|
||||
public:
|
||||
DismissHeroContextBuilder(const Nullkiller * ai) : ai(ai) {}
|
||||
DismissHeroContextBuilder(const Nullkiller2 * ai) : ai(ai) {}
|
||||
|
||||
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
|
||||
{
|
||||
@@ -1263,7 +1276,7 @@ uint64_t RewardEvaluator::getUpgradeArmyReward(const CGTownInstance * town, cons
|
||||
return upgradedPower - creaturesToUpgrade.power;
|
||||
}
|
||||
|
||||
PriorityEvaluator::PriorityEvaluator(const Nullkiller * ai)
|
||||
PriorityEvaluator::PriorityEvaluator(const Nullkiller2 * ai)
|
||||
:ai(ai)
|
||||
{
|
||||
initVisitTile();
|
||||
@@ -1316,7 +1329,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
+ (evaluationContext.skillReward > 0 ? 1 : 0)
|
||||
+ (evaluationContext.strategicalValue > 0 ? 1 : 0);
|
||||
|
||||
float goldRewardPerTurn = evaluationContext.goldReward / std::log2f(2 + evaluationContext.movementCost * 10);
|
||||
float goldRewardVsMovement = evaluationContext.goldReward / std::log2f(2 + evaluationContext.movementCost * 10);
|
||||
|
||||
double result = 0;
|
||||
|
||||
@@ -1329,7 +1342,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
heroRoleVariable->setValue(evaluationContext.heroRole);
|
||||
mainTurnDistanceVariable->setValue(evaluationContext.movementCostByRole[HeroRole::MAIN]);
|
||||
scoutTurnDistanceVariable->setValue(evaluationContext.movementCostByRole[HeroRole::SCOUT]);
|
||||
goldRewardVariable->setValue(goldRewardPerTurn);
|
||||
goldRewardVsMovementVariable->setValue(goldRewardVsMovement);
|
||||
armyRewardVariable->setValue(evaluationContext.armyReward);
|
||||
armyGrowthVariable->setValue(evaluationContext.armyGrowth);
|
||||
skillRewardVariable->setValue(evaluationContext.skillReward);
|
||||
@@ -1362,14 +1375,15 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
if (currentTileThreat.fastestDanger.turn < 1 && currentTileThreat.fastestDanger.danger > task->hero->getTotalStrength())
|
||||
currentPositionThreatened = true;
|
||||
}
|
||||
if (priorityTier == PriorityTier::FAR_HUNTER_GATHER && currentPositionThreatened == false)
|
||||
if (priorityTier == PriorityTier::FAR_HUNTER_GATHER && currentPositionThreatened == true)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Skip FAR_HUNTER_GATHER because hero is not threatened.");
|
||||
logAi->trace("Skip FAR_HUNTER_GATHER because hero would be threatened.");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
const bool amIInDanger = ai->cb->getTownsInfo().empty();
|
||||
// Shouldn't it default to 0 instead of 1.0 in the end?
|
||||
const float maxWillingToLose = amIInDanger ? 1 : ai->settings->getMaxArmyLossTarget() * evaluationContext.powerRatio > 0 ? ai->settings->getMaxArmyLossTarget() * evaluationContext.powerRatio : 1.0;
|
||||
float dangerThreshold = 1;
|
||||
dangerThreshold *= evaluationContext.powerRatio > 0 ? evaluationContext.powerRatio : 1.0;
|
||||
@@ -1379,7 +1393,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
arriveNextWeek = true;
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
logAi->trace("BEFORE: priorityTier %d, Evaluated %s, loss: %f, maxWillingToLose: %f, turn: %d, turns main: %f, scout: %f, army-involvement: %f, gold: %f, cost: %d, army gain: %f, army growth: %f skill: %f danger: %d, threatTurns: %d, threat: %d, role: %s, strategical value: %f, conquest value: %f cwr: %f, fear: %f, dangerThreshold: %f explorePriority: %d isDefend: %d isEnemy: %d arriveNextWeek: %d powerRatio: %f",
|
||||
logAi->trace("BEFORE: priorityTier %d, Evaluated %s, loss: %f, maxWillingToLose: %f, turn: %d, turns main: %f, scout: %f, armyInvolvement: %f, goldRewardVsMovement: %f, cost: %d, armyReward: %f, armyGrowth: %f skillReward: %f danger: %d, threatTurns: %d, threat: %d, heroRole: %s, strategicalValue: %f, conquestValue: %f closestWayRatio: %f, enemyHeroDangerRatio: %f, dangerThreshold: %f explorePriority: %d isDefend: %d isEnemy: %d arriveNextWeek: %d powerRatio: %f",
|
||||
priorityTier,
|
||||
task->toString(),
|
||||
evaluationContext.armyLossPersentage,
|
||||
@@ -1388,7 +1402,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
evaluationContext.movementCostByRole[HeroRole::MAIN],
|
||||
evaluationContext.movementCostByRole[HeroRole::SCOUT],
|
||||
evaluationContext.armyInvolvement,
|
||||
goldRewardPerTurn,
|
||||
goldRewardVsMovement,
|
||||
evaluationContext.goldCost,
|
||||
evaluationContext.armyReward,
|
||||
evaluationContext.armyGrowth,
|
||||
@@ -1498,6 +1512,11 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
case PriorityTier::HUNTER_GATHER: //Collect guarded stuff
|
||||
//FALL_THROUGH
|
||||
case PriorityTier::FAR_HUNTER_GATHER:
|
||||
// FIXME: Should not go to something that gives army if no slots available in the hero, but probably not in the evaluator, but in the finder
|
||||
// task.get()->hero->getSlotFor(creature, 7) == false (not sure I get to know which creature is there in Orc Tower building)
|
||||
// /// so I can't know for sure if it fits my stacks or not, but at least we can avoid going there with all 7 stacks occupied by other units
|
||||
// task.get()->hero->getFreeSlots(7) == 7
|
||||
// getDuplicatingSlots(task.get()->hero) == false
|
||||
{
|
||||
if (evaluationContext.enemyHeroDangerRatio > dangerThreshold && !evaluationContext.isDefend && priorityTier != PriorityTier::FAR_HUNTER_GATHER)
|
||||
return 0;
|
||||
@@ -1518,15 +1537,31 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
score += evaluationContext.skillReward * evaluationContext.armyInvolvement * (1 - evaluationContext.armyLossPersentage) * 0.05;
|
||||
score += evaluationContext.armyReward;
|
||||
score += evaluationContext.armyGrowth;
|
||||
score -= evaluationContext.goldCost;
|
||||
score -= evaluationContext.armyInvolvement * evaluationContext.armyLossPersentage;
|
||||
// score -= evaluationContext.goldCost; // don't include School of Magic cost or others because those locations are benefficial
|
||||
score -= evaluationContext.armyInvolvement * evaluationContext.armyLossPersentage * 0.1;
|
||||
logAi->trace("case PriorityTier::FAR_HUNTER_GATHER score %f, strategicalValue %f, goldReward %f, skillRewardMultiplied %f, armyReward %f, armyGrowth %f, goldCost -%f, armyInvolvementMultiplied -%f, "
|
||||
"armyLossPersentage %f, movementCost %f, enemyHeroDangerRatio %f",
|
||||
score, evaluationContext.strategicalValue, evaluationContext.goldReward, evaluationContext.skillReward * evaluationContext.armyInvolvement * (1 - evaluationContext.armyLossPersentage) * 0.05,
|
||||
evaluationContext.armyReward, evaluationContext.armyGrowth, evaluationContext.goldCost, evaluationContext.armyInvolvement * evaluationContext.armyLossPersentage,
|
||||
evaluationContext.armyLossPersentage, evaluationContext.movementCost, evaluationContext.enemyHeroDangerRatio);
|
||||
if (score > 0)
|
||||
{
|
||||
score = 1000;
|
||||
if (evaluationContext.movementCost > 0)
|
||||
score /= evaluationContext.movementCost;
|
||||
if(priorityTier == PriorityTier::FAR_HUNTER_GATHER && evaluationContext.enemyHeroDangerRatio > 0)
|
||||
score /= evaluationContext.enemyHeroDangerRatio;
|
||||
{
|
||||
logAi->trace("case PriorityTier::FAR_HUNTER_GATHER if 8");
|
||||
score -= evaluationContext.movementCost / 20 * score; // we expect movement won't be over 20 turns
|
||||
}
|
||||
if(evaluationContext.enemyHeroDangerRatio > 0) // This doesn't make sense at it always seems to be 0
|
||||
{
|
||||
logAi->trace("case PriorityTier::FAR_HUNTER_GATHER if 9");
|
||||
score *= 1 - evaluationContext.enemyHeroDangerRatio;
|
||||
}
|
||||
if(evaluationContext.armyLossPersentage > 0)
|
||||
{
|
||||
logAi->trace("case PriorityTier::FAR_HUNTER_GATHER if 10");
|
||||
score *= 1 - evaluationContext.armyLossPersentage;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1623,7 +1658,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
evaluationContext.movementCostByRole[HeroRole::MAIN],
|
||||
evaluationContext.movementCostByRole[HeroRole::SCOUT],
|
||||
evaluationContext.armyInvolvement,
|
||||
goldRewardPerTurn,
|
||||
goldRewardVsMovement,
|
||||
evaluationContext.goldCost,
|
||||
evaluationContext.armyReward,
|
||||
evaluationContext.armyGrowth,
|
||||
|
||||
@@ -24,15 +24,15 @@ namespace NKAI
|
||||
{
|
||||
|
||||
class BuildingInfo;
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
struct HitMapInfo;
|
||||
|
||||
class RewardEvaluator
|
||||
{
|
||||
public:
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
|
||||
RewardEvaluator(const Nullkiller * ai) : ai(ai) {}
|
||||
RewardEvaluator(const Nullkiller2 * ai) : ai(ai) {}
|
||||
|
||||
uint64_t getArmyReward(const CGObjectInstance * target, const CGHeroInstance * hero, const CCreatureSet * army, bool checkGold) const;
|
||||
uint64_t getArmyGrowth(const CGObjectInstance * target, const CGHeroInstance * hero, const CCreatureSet * army) const;
|
||||
@@ -86,7 +86,7 @@ struct DLL_EXPORT EvaluationContext
|
||||
int explorePriority;
|
||||
float powerRatio;
|
||||
|
||||
EvaluationContext(const Nullkiller * ai);
|
||||
EvaluationContext(const Nullkiller2 * ai);
|
||||
|
||||
void addNonCriticalStrategicalValue(float value);
|
||||
};
|
||||
@@ -98,12 +98,12 @@ public:
|
||||
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal goal) const = 0;
|
||||
};
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
class PriorityEvaluator
|
||||
{
|
||||
public:
|
||||
PriorityEvaluator(const Nullkiller * ai);
|
||||
PriorityEvaluator(const Nullkiller2 * ai);
|
||||
~PriorityEvaluator();
|
||||
void initVisitTile();
|
||||
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
|
||||
fl::Engine * engine;
|
||||
fl::InputVariable * armyLossPersentageVariable;
|
||||
@@ -133,7 +133,7 @@ private:
|
||||
fl::InputVariable * mainTurnDistanceVariable;
|
||||
fl::InputVariable * scoutTurnDistanceVariable;
|
||||
fl::InputVariable * turnVariable;
|
||||
fl::InputVariable * goldRewardVariable;
|
||||
fl::InputVariable * goldRewardVsMovementVariable;
|
||||
fl::InputVariable * armyRewardVariable;
|
||||
fl::InputVariable * armyGrowthVariable;
|
||||
fl::InputVariable * dangerVariable;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace NKAI
|
||||
struct HeroPtr;
|
||||
class AIGateway;
|
||||
class FuzzyHelper;
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
namespace Goals
|
||||
{
|
||||
@@ -133,7 +133,7 @@ namespace Goals
|
||||
return const_cast<AbstractGoal *>(this);
|
||||
}
|
||||
|
||||
virtual TGoalVec decompose(const Nullkiller * ai) const
|
||||
virtual TGoalVec decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
return TGoalVec();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "BuyArmy.h"
|
||||
#include "../../../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
|
||||
namespace NKAI
|
||||
@@ -36,7 +36,7 @@ void BuyArmy::accept(AIGateway * ai)
|
||||
|
||||
auto upgradeSuccessful = ai->makePossibleUpgrades(town);
|
||||
|
||||
auto armyToBuy = ai->nullkiller->armyManager->getArmyAvailableToBuy(town->getUpperArmy(), town);
|
||||
auto armyToBuy = ai->nullkiller2->armyManager->getArmyAvailableToBuy(town->getUpperArmy(), town);
|
||||
|
||||
if(armyToBuy.empty())
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Goals
|
||||
|
||||
virtual bool operator==(const T & other) const = 0;
|
||||
|
||||
TGoalVec decompose(const Nullkiller * ai) const override
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override
|
||||
{
|
||||
TSubgoal single = decomposeSingle(ai);
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Goals
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual TSubgoal decomposeSingle(const Nullkiller * ai) const
|
||||
virtual TSubgoal decomposeSingle(const Nullkiller2 * ai) const
|
||||
{
|
||||
return TSubgoal();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "CaptureObject.h"
|
||||
#include "../../../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../Behaviors/CaptureObjectsBehavior.h"
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ std::string CaptureObject::toString() const
|
||||
return "Capture " + name + " at " + tile.toString();
|
||||
}
|
||||
|
||||
TGoalVec CaptureObject::decompose(const Nullkiller * ai) const
|
||||
TGoalVec CaptureObject::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
return CaptureObjectsBehavior(ai->cb->getObj(ObjectInstanceID(objid))).decompose(ai);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Goals
|
||||
}
|
||||
|
||||
bool operator==(const CaptureObject & other) const override;
|
||||
Goals::TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
Goals::TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
bool hasHash() const override { return true; }
|
||||
uint64_t getHash() const override;
|
||||
|
||||
@@ -31,7 +31,7 @@ std::string CompleteQuest::toString() const
|
||||
return "Complete quest " + questToString();
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::decompose(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
if(isKeyMaster(q))
|
||||
{
|
||||
@@ -106,7 +106,7 @@ std::string CompleteQuest::questToString() const
|
||||
return ms.toString();
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::tryCompleteQuest(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::tryCompleteQuest(const Nullkiller2 * ai) const
|
||||
{
|
||||
auto paths = ai->pathfinder->getPathInfo(q.getObject(cb)->visitablePos());
|
||||
|
||||
@@ -118,7 +118,7 @@ TGoalVec CompleteQuest::tryCompleteQuest(const Nullkiller * ai) const
|
||||
return CaptureObjectsBehavior::getVisitGoals(paths, ai, q.getObject(cb));
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionArt(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionArt(const Nullkiller2 * ai) const
|
||||
{
|
||||
TGoalVec solutions = tryCompleteQuest(ai);
|
||||
|
||||
@@ -135,7 +135,7 @@ TGoalVec CompleteQuest::missionArt(const Nullkiller * ai) const
|
||||
return solutions;
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionHero(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionHero(const Nullkiller2 * ai) const
|
||||
{
|
||||
TGoalVec solutions = tryCompleteQuest(ai);
|
||||
|
||||
@@ -148,7 +148,7 @@ TGoalVec CompleteQuest::missionHero(const Nullkiller * ai) const
|
||||
return solutions;
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionArmy(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionArmy(const Nullkiller2 * ai) const
|
||||
{
|
||||
auto paths = ai->pathfinder->getPathInfo(q.getObject(cb)->visitablePos());
|
||||
|
||||
@@ -160,17 +160,17 @@ TGoalVec CompleteQuest::missionArmy(const Nullkiller * ai) const
|
||||
return CaptureObjectsBehavior::getVisitGoals(paths, ai, q.getObject(cb));
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionIncreasePrimaryStat(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionIncreasePrimaryStat(const Nullkiller2 * ai) const
|
||||
{
|
||||
return tryCompleteQuest(ai);
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionLevel(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionLevel(const Nullkiller2 * ai) const
|
||||
{
|
||||
return tryCompleteQuest(ai);
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionKeymaster(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionKeymaster(const Nullkiller2 * ai) const
|
||||
{
|
||||
if(isObjectPassable(ai, q.getObject(cb)))
|
||||
{
|
||||
@@ -182,13 +182,13 @@ TGoalVec CompleteQuest::missionKeymaster(const Nullkiller * ai) const
|
||||
}
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionResources(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionResources(const Nullkiller2 * ai) const
|
||||
{
|
||||
TGoalVec solutions = tryCompleteQuest(ai);
|
||||
return solutions;
|
||||
}
|
||||
|
||||
TGoalVec CompleteQuest::missionDestroyObj(const Nullkiller * ai) const
|
||||
TGoalVec CompleteQuest::missionDestroyObj(const Nullkiller2 * ai) const
|
||||
{
|
||||
auto obj = ai->cb->getObj(q.getQuest(cb)->killTarget);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Goals
|
||||
{
|
||||
}
|
||||
|
||||
Goals::TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
Goals::TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
std::string toString() const override;
|
||||
bool hasHash() const override { return true; }
|
||||
uint64_t getHash() const override;
|
||||
@@ -36,15 +36,15 @@ namespace Goals
|
||||
bool operator==(const CompleteQuest & other) const override;
|
||||
|
||||
private:
|
||||
TGoalVec tryCompleteQuest(const Nullkiller * ai) const;
|
||||
TGoalVec missionArt(const Nullkiller * ai) const;
|
||||
TGoalVec missionHero(const Nullkiller * ai) const;
|
||||
TGoalVec missionArmy(const Nullkiller * ai) const;
|
||||
TGoalVec missionResources(const Nullkiller * ai) const;
|
||||
TGoalVec missionDestroyObj(const Nullkiller * ai) const;
|
||||
TGoalVec missionIncreasePrimaryStat(const Nullkiller * ai) const;
|
||||
TGoalVec missionLevel(const Nullkiller * ai) const;
|
||||
TGoalVec missionKeymaster(const Nullkiller * ai) const;
|
||||
TGoalVec tryCompleteQuest(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionArt(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionHero(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionArmy(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionResources(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionDestroyObj(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionIncreasePrimaryStat(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionLevel(const Nullkiller2 * ai) const;
|
||||
TGoalVec missionKeymaster(const Nullkiller2 * ai) const;
|
||||
std::string questToString() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void Composition::accept(AIGateway * ai)
|
||||
}
|
||||
}
|
||||
|
||||
TGoalVec Composition::decompose(const Nullkiller * ai) const
|
||||
TGoalVec Composition::decompose(const Nullkiller2 * ai) const
|
||||
{
|
||||
TGoalVec result;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Goals
|
||||
Composition & addNext(const AbstractGoal & goal);
|
||||
Composition & addNext(TSubgoal goal);
|
||||
Composition & addNextSequence(const TGoalVec & taskSequence);
|
||||
TGoalVec decompose(const Nullkiller * ai) const override;
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override;
|
||||
bool isElementar() const override;
|
||||
int getHeroExchangeCount() const override;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "ExchangeSwapTownHeroes.h"
|
||||
#include "ExecuteHeroChain.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
@@ -74,7 +74,7 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
|
||||
}
|
||||
|
||||
ai->buildArmyIn(town);
|
||||
ai->nullkiller->unlockHero(currentGarrisonHero);
|
||||
ai->nullkiller2->unlockHero(currentGarrisonHero);
|
||||
logAi->debug("Extracted hero %s from garrison of %s", currentGarrisonHero->getNameTranslated(), town->getNameTranslated());
|
||||
|
||||
return;
|
||||
@@ -103,12 +103,12 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
|
||||
|
||||
if(lockingReason != HeroLockedReason::NOT_LOCKED)
|
||||
{
|
||||
ai->nullkiller->lockHero(getGarrisonHero(), lockingReason);
|
||||
ai->nullkiller2->lockHero(getGarrisonHero(), lockingReason);
|
||||
}
|
||||
|
||||
if(town->getVisitingHero() && town->getVisitingHero() != getGarrisonHero())
|
||||
{
|
||||
ai->nullkiller->unlockHero(town->getVisitingHero());
|
||||
ai->nullkiller2->unlockHero(town->getVisitingHero());
|
||||
ai->makePossibleUpgrades(town->getVisitingHero());
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CGoal.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "ExecuteHeroChain.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
@@ -84,9 +84,9 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
{
|
||||
logAi->debug("Executing hero chain towards %s. Path %s", targetName, chainPath.toString());
|
||||
|
||||
ai->nullkiller->setActive(chainPath.targetHero, tile);
|
||||
ai->nullkiller->setTargetObject(objid);
|
||||
ai->nullkiller->objectClusterizer->reset();
|
||||
ai->nullkiller2->setActive(chainPath.targetHero, tile);
|
||||
ai->nullkiller2->setTargetObject(objid);
|
||||
ai->nullkiller2->objectClusterizer->reset();
|
||||
|
||||
auto targetObject = ai->myCb->getObj(static_cast<ObjectInstanceID>(objid), false);
|
||||
|
||||
@@ -96,7 +96,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
|
||||
if(relations == PlayerRelations::ENEMIES)
|
||||
{
|
||||
ai->nullkiller->armyFormation->rearrangeArmyForSiege(
|
||||
ai->nullkiller2->armyFormation->rearrangeArmyForSiege(
|
||||
dynamic_cast<const CGTownInstance *>(targetObject),
|
||||
chainPath.targetHero);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
if(vstd::contains(blockedIndexes, i))
|
||||
{
|
||||
blockedIndexes.insert(node->parentIndex);
|
||||
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
|
||||
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
{
|
||||
if(hero->movementPointsRemaining() > 0)
|
||||
{
|
||||
ai->nullkiller->setActive(hero, node->coord);
|
||||
ai->nullkiller2->setActive(hero, node->coord);
|
||||
|
||||
if(node->specialAction)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(i > 0 && ai->nullkiller->isObjectGraphAllowed())
|
||||
else if(i > 0 && ai->nullkiller2->isObjectGraphAllowed())
|
||||
{
|
||||
auto chainMask = i < chainPath.nodes.size() - 1 ? chainPath.nodes[i + 1].chainMask : node->chainMask;
|
||||
|
||||
@@ -166,7 +166,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
if(nextNode.specialAction || nextNode.chainMask != chainMask)
|
||||
break;
|
||||
|
||||
auto targetNode = ai->nullkiller->getPathsInfo(hero)->getPathInfo(nextNode.coord);
|
||||
auto targetNode = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(nextNode.coord);
|
||||
|
||||
if(!targetNode->reachable()
|
||||
|| targetNode->getCost() > nextNode.cost)
|
||||
@@ -182,7 +182,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
|
||||
if(node->turns == 0 && node->coord != hero->visitablePos())
|
||||
{
|
||||
auto targetNode = ai->nullkiller->getPathsInfo(hero)->getPathInfo(node->coord);
|
||||
auto targetNode = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(node->coord);
|
||||
|
||||
if(targetNode->accessible == EPathAccessibility::NOT_SET
|
||||
|| targetNode->accessible == EPathAccessibility::BLOCKED
|
||||
@@ -239,13 +239,13 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
if(hero->movementPointsRemaining() > 0)
|
||||
{
|
||||
CGPath path;
|
||||
bool isOk = ai->nullkiller->getPathsInfo(hero)->getPath(path, node->coord);
|
||||
bool isOk = ai->nullkiller2->getPathsInfo(hero)->getPath(path, node->coord);
|
||||
|
||||
if(isOk && path.nodes.back().turns > 0)
|
||||
{
|
||||
logAi->warn("Hero %s has %d mp which is not enough to continue his way towards %s.", hero->getNameTranslated(), hero->movementPointsRemaining(), node->coord.toString());
|
||||
|
||||
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
|
||||
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
}
|
||||
|
||||
// no exception means we were not able to reach the tile
|
||||
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
|
||||
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
|
||||
blockedIndexes.insert(node->parentIndex);
|
||||
}
|
||||
catch(const goalFulfilledException &)
|
||||
|
||||
@@ -26,7 +26,7 @@ bool ExploreNeighbourTile::operator==(const ExploreNeighbourTile & other) const
|
||||
|
||||
void ExploreNeighbourTile::accept(AIGateway * ai)
|
||||
{
|
||||
ExplorationHelper h(hero, ai->nullkiller.get(), true);
|
||||
ExplorationHelper h(hero, ai->nullkiller2.get(), true);
|
||||
|
||||
for(int i = 0; i < tilesToExplore && ai->myCb->getObj(hero->id, false) && hero->movementPointsRemaining() > 0; i++)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
|
||||
int3 target = int3(-1);
|
||||
foreach_neighbour(pos, [&](int3 tile)
|
||||
{
|
||||
auto pathInfo = ai->nullkiller->getPathsInfo(hero)->getPathInfo(tile);
|
||||
auto pathInfo = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(tile);
|
||||
|
||||
if(pathInfo->turns > 0)
|
||||
return;
|
||||
@@ -59,7 +59,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
|
||||
return;
|
||||
}
|
||||
|
||||
auto danger = ai->nullkiller->dangerEvaluator->evaluateDanger(target, hero, true);
|
||||
auto danger = ai->nullkiller2->dangerEvaluator->evaluateDanger(target, hero, true);
|
||||
|
||||
if(danger > 0 || !ai->moveHeroToTile(target, hero))
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Goals
|
||||
{
|
||||
priority = -1;
|
||||
}
|
||||
TGoalVec decompose(const Nullkiller * ai) const override
|
||||
TGoalVec decompose(const Nullkiller2 * ai) const override
|
||||
{
|
||||
return TGoalVec();
|
||||
}
|
||||
|
||||
@@ -70,10 +70,10 @@ void RecruitHero::accept(AIGateway * ai)
|
||||
cb->recruitHero(t, heroToHire);
|
||||
|
||||
{
|
||||
std::unique_lock lockGuard(ai->nullkiller->aiStateMutex);
|
||||
std::unique_lock lockGuard(ai->nullkiller2->aiStateMutex);
|
||||
|
||||
ai->nullkiller->heroManager->update();
|
||||
ai->nullkiller->objectClusterizer->reset();
|
||||
ai->nullkiller2->heroManager->update();
|
||||
ai->nullkiller2->objectClusterizer->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ bool SaveResources::operator==(const SaveResources & other) const
|
||||
|
||||
void SaveResources::accept(AIGateway * ai)
|
||||
{
|
||||
ai->nullkiller->lockResources(resources);
|
||||
ai->nullkiller2->lockResources(resources);
|
||||
|
||||
logAi->debug("Locked %s resources", resources.toString());
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "StayAtTown.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
|
||||
namespace NKAI
|
||||
@@ -42,7 +42,7 @@ std::string StayAtTown::toString() const
|
||||
|
||||
void StayAtTown::accept(AIGateway * ai)
|
||||
{
|
||||
ai->nullkiller->lockHero(hero, HeroLockedReason::DEFENCE);
|
||||
ai->nullkiller2->lockHero(hero, HeroLockedReason::DEFENCE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace NKAI
|
||||
struct HeroPtr;
|
||||
class AIGateway;
|
||||
class FuzzyHelper;
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
class DLL_EXPORT ArmyFormation
|
||||
{
|
||||
@@ -28,7 +28,7 @@ private:
|
||||
std::shared_ptr<CCallback> cb; //this is enough, but we downcast from CCallback
|
||||
|
||||
public:
|
||||
ArmyFormation(std::shared_ptr<CCallback> CB, const Nullkiller * ai): cb(CB) {}
|
||||
ArmyFormation(std::shared_ptr<CCallback> CB, const Nullkiller2 * ai): cb(CB) {}
|
||||
|
||||
void rearrangeArmyForSiege(const CGTownInstance * town, const CGHeroInstance * attacker);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "ExplorationHelper.h"
|
||||
#include "../../../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../Goals/Invalid.h"
|
||||
#include "../Goals/Composition.h"
|
||||
#include "../Goals/ExecuteHeroChain.h"
|
||||
@@ -24,7 +24,7 @@ namespace NKAI
|
||||
|
||||
using namespace Goals;
|
||||
|
||||
ExplorationHelper::ExplorationHelper(const CGHeroInstance * hero, const Nullkiller * ai, bool useCPathfinderAccessibility)
|
||||
ExplorationHelper::ExplorationHelper(const CGHeroInstance * hero, const Nullkiller2 * ai, bool useCPathfinderAccessibility)
|
||||
:ai(ai), cbp(ai->cb.get()), hero(hero), useCPathfinderAccessibility(useCPathfinderAccessibility)
|
||||
{
|
||||
ts = cbp->getPlayerTeam(ai->playerID);
|
||||
|
||||
@@ -27,7 +27,7 @@ private:
|
||||
Goals::TSubgoal bestGoal;
|
||||
int3 bestTile;
|
||||
int bestTilesDiscovered;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
CCallback * cbp;
|
||||
const TeamState * ts;
|
||||
int3 ourPos;
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
bool useCPathfinderAccessibility;
|
||||
|
||||
public:
|
||||
ExplorationHelper(const CGHeroInstance * hero, const Nullkiller * ai, bool useCPathfinderAccessibility = false);
|
||||
ExplorationHelper(const CGHeroInstance * hero, const Nullkiller2 * ai, bool useCPathfinderAccessibility = false);
|
||||
Goals::TSubgoal makeComposition() const;
|
||||
bool scanSector(int scanRadius);
|
||||
bool scanMap();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "ArmyUpgrade.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
|
||||
namespace NKAI
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "DefendTown.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
|
||||
namespace NKAI
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "ExplorationPoint.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
#include "../Analyzers/ArmyManager.h"
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "HeroExchange.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
#include "../Analyzers/ArmyManager.h"
|
||||
|
||||
@@ -29,7 +29,7 @@ std::string HeroExchange::toString() const
|
||||
return "Hero exchange for " +hero->getObjectName() + " by " + exchangePath.toString();
|
||||
}
|
||||
|
||||
uint64_t HeroExchange::getReinforcementArmyStrength(const Nullkiller * ai) const
|
||||
uint64_t HeroExchange::getReinforcementArmyStrength(const Nullkiller2 * ai) const
|
||||
{
|
||||
uint64_t armyValue = ai->armyManager->howManyReinforcementsCanGet(hero, exchangePath.heroArmy);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Goals
|
||||
bool operator==(const HeroExchange & other) const override;
|
||||
std::string toString() const override;
|
||||
|
||||
uint64_t getReinforcementArmyStrength(const Nullkiller * ai) const;
|
||||
uint64_t getReinforcementArmyStrength(const Nullkiller2 * ai) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "UnlockCluster.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../AIUtility.h"
|
||||
|
||||
namespace NKAI
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "AINodeStorage.h"
|
||||
#include "Actions/TownPortalAction.h"
|
||||
#include "Actions/WhirlpoolAction.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/callback/IGameInfoCallback.h"
|
||||
#include "../../../lib/mapping/CMap.h"
|
||||
#include "../../../lib/pathfinder/CPathfinder.h"
|
||||
@@ -102,7 +102,7 @@ int AINodeStorage::getBucketSize() const
|
||||
return ai->settings->getPathfinderBucketSize();
|
||||
}
|
||||
|
||||
AINodeStorage::AINodeStorage(const Nullkiller * ai, const int3 & Sizes)
|
||||
AINodeStorage::AINodeStorage(const Nullkiller2 * ai, const int3 & Sizes)
|
||||
: sizes(Sizes), ai(ai), cb(ai->cb.get()), nodes(Sizes, ai->settings->getPathfinderBucketSize() * ai->settings->getPathfinderBucketsCount())
|
||||
{
|
||||
accessibility = std::make_unique<boost::multi_array<EPathAccessibility, 4>>(
|
||||
|
||||
@@ -166,7 +166,7 @@ private:
|
||||
std::unique_ptr<boost::multi_array<EPathAccessibility, 4>> accessibility;
|
||||
|
||||
const CPlayerSpecificInfoCallback * cb;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
AISharedStorage nodes;
|
||||
std::vector<std::shared_ptr<ChainActor>> actors;
|
||||
std::vector<CGPathNode *> heroChain;
|
||||
@@ -179,7 +179,7 @@ private:
|
||||
|
||||
public:
|
||||
/// more than 1 chain layer for each hero allows us to have more than 1 path to each tile so we can chose more optimal one.
|
||||
AINodeStorage(const Nullkiller * ai, const int3 & sizes);
|
||||
AINodeStorage(const Nullkiller2 * ai, const int3 & sizes);
|
||||
~AINodeStorage();
|
||||
|
||||
void initialize(const PathfinderOptions & options, const IGameInfoCallback & gameInfo) override;
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include "AIPathfinder.h"
|
||||
#include "AIPathfinderConfig.h"
|
||||
#include "../../../lib/mapping/CMap.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
std::map<ObjectInstanceID, std::unique_ptr<GraphPaths>> AIPathfinder::heroGraphs;
|
||||
|
||||
AIPathfinder::AIPathfinder(CPlayerSpecificInfoCallback * cb, Nullkiller * ai)
|
||||
AIPathfinder::AIPathfinder(CPlayerSpecificInfoCallback * cb, Nullkiller2 * ai)
|
||||
:cb(cb), ai(ai)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
struct PathfinderSettings
|
||||
{
|
||||
@@ -40,11 +40,11 @@ class AIPathfinder
|
||||
private:
|
||||
std::shared_ptr<AINodeStorage> storage;
|
||||
CPlayerSpecificInfoCallback * cb;
|
||||
Nullkiller * ai;
|
||||
Nullkiller2 * ai;
|
||||
static std::map<ObjectInstanceID, std::unique_ptr<GraphPaths>> heroGraphs;
|
||||
|
||||
public:
|
||||
AIPathfinder(CPlayerSpecificInfoCallback * cb, Nullkiller * ai);
|
||||
AIPathfinder(CPlayerSpecificInfoCallback * cb, Nullkiller2 * ai);
|
||||
void calculatePathInfo(std::vector<AIPath> & paths, const int3 & tile, bool includeGraph = false) const;
|
||||
bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const;
|
||||
void updatePaths(const std::map<const CGHeroInstance *, HeroRole> & heroes, PathfinderSettings pathfinderSettings);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "Rules/AIMovementAfterDestinationRule.h"
|
||||
#include "Rules/AIMovementToDestinationRule.h"
|
||||
#include "Rules/AIPreviousNodeRule.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
|
||||
#include "../../../lib/pathfinder/CPathfinder.h"
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace AIPathfinding
|
||||
{
|
||||
std::vector<std::shared_ptr<IPathfindingRule>> makeRuleset(
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
Nullkiller * ai,
|
||||
Nullkiller2 * ai,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage,
|
||||
bool allowBypassObjects)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace AIPathfinding
|
||||
|
||||
AIPathfinderConfig::AIPathfinderConfig(
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
Nullkiller * ai,
|
||||
Nullkiller2 * ai,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage,
|
||||
bool allowBypassObjects)
|
||||
:PathfinderConfig(nodeStorage, *cb, makeRuleset(cb, ai, nodeStorage, allowBypassObjects)), aiNodeStorage(nodeStorage)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
namespace AIPathfinding
|
||||
{
|
||||
@@ -29,7 +29,7 @@ namespace AIPathfinding
|
||||
public:
|
||||
AIPathfinderConfig(
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
Nullkiller * ai,
|
||||
Nullkiller2 * ai,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage,
|
||||
bool allowBypassObjects);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace AIPathfinding
|
||||
Goals::AdventureSpellCast(hero, spellToCast).accept(ai);
|
||||
}
|
||||
|
||||
bool AdventureCastAction::canAct(const Nullkiller * ai, const AIPathNode * source) const
|
||||
bool AdventureCastAction::canAct(const Nullkiller2 * ai, const AIPathNode * source) const
|
||||
{
|
||||
assert(hero == this->hero);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace AIPathfinding
|
||||
AIPathNode * dstMode,
|
||||
const AIPathNode * srcNode) const override;
|
||||
|
||||
bool canAct(const Nullkiller * ai, const AIPathNode * source) const override;
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNode * source) const override;
|
||||
|
||||
std::string toString() const override;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace AIPathfinding
|
||||
return Goals::BuildBoat(shipyard).accept(ai);
|
||||
}
|
||||
|
||||
Goals::TSubgoal BuildBoatAction::decompose(const Nullkiller * ai, const CGHeroInstance * hero) const
|
||||
Goals::TSubgoal BuildBoatAction::decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const
|
||||
{
|
||||
if(cb->getPlayerRelations(ai->playerID, shipyard->getObject()->getOwner()) == PlayerRelations::ENEMIES)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace AIPathfinding
|
||||
return Goals::sptr(Goals::Invalid());
|
||||
}
|
||||
|
||||
bool BuildBoatAction::canAct(const Nullkiller * ai, const CGHeroInstance * hero, const TResources & reservedResources) const
|
||||
bool BuildBoatAction::canAct(const Nullkiller2 * ai, const CGHeroInstance * hero, const TResources & reservedResources) const
|
||||
{
|
||||
if(cb->getPlayerRelations(hero->tempOwner, shipyard->getObject()->getOwner()) == PlayerRelations::ENEMIES)
|
||||
{
|
||||
@@ -63,12 +63,12 @@ namespace AIPathfinding
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuildBoatAction::canAct(const Nullkiller * ai, const AIPathNode * source) const
|
||||
bool BuildBoatAction::canAct(const Nullkiller2 * ai, const AIPathNode * source) const
|
||||
{
|
||||
return canAct(ai, source->actor->hero, source->actor->armyCost);
|
||||
}
|
||||
|
||||
bool BuildBoatAction::canAct(const Nullkiller * ai, const AIPathNodeInfo & source) const
|
||||
bool BuildBoatAction::canAct(const Nullkiller2 * ai, const AIPathNodeInfo & source) const
|
||||
{
|
||||
TResources res;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace AIPathfinding
|
||||
return sourceActor->resourceActor;
|
||||
}
|
||||
|
||||
std::shared_ptr<SpecialAction> BuildBoatActionFactory::create(const Nullkiller * ai)
|
||||
std::shared_ptr<SpecialAction> BuildBoatActionFactory::create(const Nullkiller2 * ai)
|
||||
{
|
||||
return std::make_shared<BuildBoatAction>(ai->cb.get(), dynamic_cast<const IShipyard * >(ai->cb->getObj(shipyard)));
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace AIPathfinding
|
||||
return "Build Boat at " + shipyard->getObject()->visitablePos().toString();
|
||||
}
|
||||
|
||||
bool SummonBoatAction::canAct(const Nullkiller * ai, const AIPathNode * source) const
|
||||
bool SummonBoatAction::canAct(const Nullkiller2 * ai, const AIPathNode * source) const
|
||||
{
|
||||
auto hero = source->actor->hero;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace AIPathfinding
|
||||
AIPathNode * dstMode,
|
||||
const AIPathNode * srcNode) const override;
|
||||
|
||||
bool canAct(const Nullkiller * ai, const AIPathNode * source) const override;
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNode * source) const override;
|
||||
|
||||
const ChainActor * getActor(const ChainActor * sourceActor) const override;
|
||||
|
||||
@@ -62,13 +62,13 @@ namespace AIPathfinding
|
||||
{
|
||||
}
|
||||
|
||||
bool canAct(const Nullkiller * ai, const AIPathNode * source) const override;
|
||||
bool canAct(const Nullkiller * ai, const AIPathNodeInfo & source) const override;
|
||||
bool canAct(const Nullkiller * ai, const CGHeroInstance * hero, const TResources & reservedResources) const;
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNode * source) const override;
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNodeInfo & source) const override;
|
||||
bool canAct(const Nullkiller2 * ai, const CGHeroInstance * hero, const TResources & reservedResources) const;
|
||||
|
||||
void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
|
||||
|
||||
Goals::TSubgoal decompose(const Nullkiller * ai, const CGHeroInstance * hero) const override;
|
||||
Goals::TSubgoal decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const override;
|
||||
|
||||
const ChainActor * getActor(const ChainActor * sourceActor) const override;
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace AIPathfinding
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<SpecialAction> create(const Nullkiller * ai) override;
|
||||
std::shared_ptr<SpecialAction> create(const Nullkiller2 * ai) override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace AIPathfinding
|
||||
private:
|
||||
|
||||
public:
|
||||
bool canAct(const Nullkiller * ai, const AIPathNode * source) const override
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNode * source) const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace NKAI
|
||||
|
||||
namespace AIPathfinding
|
||||
{
|
||||
bool QuestAction::canAct(const Nullkiller * ai, const AIPathNode * node) const
|
||||
bool QuestAction::canAct(const Nullkiller2 * ai, const AIPathNode * node) const
|
||||
{
|
||||
return canAct(ai, node->actor->hero);
|
||||
}
|
||||
|
||||
bool QuestAction::canAct(const Nullkiller * ai, const AIPathNodeInfo & node) const
|
||||
bool QuestAction::canAct(const Nullkiller2 * ai, const AIPathNodeInfo & node) const
|
||||
{
|
||||
return canAct(ai, node.targetHero);
|
||||
}
|
||||
|
||||
bool QuestAction::canAct(const Nullkiller * ai, const CGHeroInstance * hero) const
|
||||
bool QuestAction::canAct(const Nullkiller2 * ai, const CGHeroInstance * hero) const
|
||||
{
|
||||
auto object = questInfo.getObject(ai->cb.get());
|
||||
auto quest = questInfo.getQuest(ai->cb.get());
|
||||
@@ -45,7 +45,7 @@ namespace AIPathfinding
|
||||
|| quest->checkQuest(hero);
|
||||
}
|
||||
|
||||
Goals::TSubgoal QuestAction::decompose(const Nullkiller * ai, const CGHeroInstance * hero) const
|
||||
Goals::TSubgoal QuestAction::decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const
|
||||
{
|
||||
return Goals::sptr(Goals::CompleteQuest(questInfo));
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace AIPathfinding
|
||||
{
|
||||
}
|
||||
|
||||
bool canAct(const Nullkiller * ai, const AIPathNode * node) const override;
|
||||
bool canAct(const Nullkiller * ai, const AIPathNodeInfo & node) const override;
|
||||
bool canAct(const Nullkiller * ai, const CGHeroInstance * hero) const;
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNode * node) const override;
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNodeInfo & node) const override;
|
||||
bool canAct(const Nullkiller2 * ai, const CGHeroInstance * hero) const;
|
||||
|
||||
Goals::TSubgoal decompose(const Nullkiller * ai, const CGHeroInstance * hero) const override;
|
||||
Goals::TSubgoal decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const override;
|
||||
|
||||
void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
Goals::TSubgoal SpecialAction::decompose(const Nullkiller * ai, const CGHeroInstance * hero) const
|
||||
Goals::TSubgoal SpecialAction::decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const
|
||||
{
|
||||
return Goals::sptr(Goals::Invalid());
|
||||
}
|
||||
@@ -27,7 +27,7 @@ void SpecialAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
|
||||
throw cannotFulfillGoalException("Can not execute " + toString());
|
||||
}
|
||||
|
||||
bool CompositeAction::canAct(const Nullkiller * ai, const AIPathNode * source) const
|
||||
bool CompositeAction::canAct(const Nullkiller2 * ai, const AIPathNode * source) const
|
||||
{
|
||||
for(auto part : parts)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ bool CompositeAction::canAct(const Nullkiller * ai, const AIPathNode * source) c
|
||||
return true;
|
||||
}
|
||||
|
||||
Goals::TSubgoal CompositeAction::decompose(const Nullkiller * ai, const CGHeroInstance * hero) const
|
||||
Goals::TSubgoal CompositeAction::decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const
|
||||
{
|
||||
for(auto part : parts)
|
||||
{
|
||||
|
||||
@@ -30,17 +30,17 @@ class SpecialAction
|
||||
public:
|
||||
virtual ~SpecialAction() = default;
|
||||
|
||||
virtual bool canAct(const Nullkiller * ai, const AIPathNode * source) const
|
||||
virtual bool canAct(const Nullkiller2 * ai, const AIPathNode * source) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool canAct(const Nullkiller * ai, const AIPathNodeInfo & source) const
|
||||
virtual bool canAct(const Nullkiller2 * ai, const AIPathNodeInfo & source) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual Goals::TSubgoal decompose(const Nullkiller * ai, const CGHeroInstance * hero) const;
|
||||
virtual Goals::TSubgoal decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const;
|
||||
|
||||
virtual void execute(AIGateway * ai, const CGHeroInstance * hero) const;
|
||||
|
||||
@@ -76,11 +76,11 @@ private:
|
||||
public:
|
||||
CompositeAction(std::vector<std::shared_ptr<const SpecialAction>> parts) : parts(parts) {}
|
||||
|
||||
bool canAct(const Nullkiller * ai, const AIPathNode * source) const override;
|
||||
bool canAct(const Nullkiller2 * ai, const AIPathNode * source) const override;
|
||||
void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
|
||||
std::string toString() const override;
|
||||
const CGObjectInstance * targetObject() const override;
|
||||
Goals::TSubgoal decompose(const Nullkiller * ai, const CGHeroInstance * hero) const override;
|
||||
Goals::TSubgoal decompose(const Nullkiller2 * ai, const CGHeroInstance * hero) const override;
|
||||
|
||||
std::vector<std::shared_ptr<const SpecialAction>> getParts() const override
|
||||
{
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
class ISpecialActionFactory
|
||||
{
|
||||
public:
|
||||
virtual std::shared_ptr<SpecialAction> create(const Nullkiller * ai) = 0;
|
||||
virtual std::shared_ptr<SpecialAction> create(const Nullkiller2 * ai) = 0;
|
||||
virtual ~ISpecialActionFactory() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ std::shared_ptr<WhirlpoolAction> WhirlpoolAction::instance = std::make_shared<Wh
|
||||
|
||||
void WhirlpoolAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
|
||||
{
|
||||
ai->nullkiller->armyFormation->rearrangeArmyForWhirlpool(hero);
|
||||
ai->nullkiller2->armyFormation->rearrangeArmyForWhirlpool(hero);
|
||||
}
|
||||
|
||||
std::string WhirlpoolAction::toString() const
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "Actors.h"
|
||||
#include "../AIGateway.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/mapObjects/MapObjects.h"
|
||||
#include "../../../lib/mapping/TerrainTile.h"
|
||||
#include "../../../lib/pathfinder/TurnInfo.h"
|
||||
@@ -97,7 +97,7 @@ std::string ObjectActor::toString() const
|
||||
return object->getObjectName() + " at " + object->visitablePos().toString();
|
||||
}
|
||||
|
||||
HeroActor::HeroActor(const CGHeroInstance * hero, HeroRole heroRole, uint64_t chainMask, const Nullkiller * ai)
|
||||
HeroActor::HeroActor(const CGHeroInstance * hero, HeroRole heroRole, uint64_t chainMask, const Nullkiller2 * ai)
|
||||
:ChainActor(hero, heroRole, chainMask)
|
||||
{
|
||||
exchangeMap.reset(new HeroExchangeMap(this, ai));
|
||||
@@ -108,7 +108,7 @@ HeroActor::HeroActor(
|
||||
const ChainActor * carrier,
|
||||
const ChainActor * other,
|
||||
const HeroExchangeArmy * army,
|
||||
const Nullkiller * ai)
|
||||
const Nullkiller2 * ai)
|
||||
:ChainActor(carrier, other, army)
|
||||
{
|
||||
exchangeMap.reset(new HeroExchangeMap(this, ai));
|
||||
@@ -185,7 +185,7 @@ ExchangeResult HeroActor::tryExchangeNoLock(const ChainActor * specialActor, con
|
||||
return result;
|
||||
}
|
||||
|
||||
HeroExchangeMap::HeroExchangeMap(const HeroActor * actor, const Nullkiller * ai)
|
||||
HeroExchangeMap::HeroExchangeMap(const HeroActor * actor, const Nullkiller2 * ai)
|
||||
:actor(actor), ai(ai), sync()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ extern const uint64_t MIN_ARMY_STRENGTH_FOR_CHAIN;
|
||||
|
||||
class ChainActor;
|
||||
class HeroActor;
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
class HeroExchangeArmy : public CArmedInstance
|
||||
{
|
||||
@@ -92,11 +92,11 @@ class HeroExchangeMap
|
||||
private:
|
||||
const HeroActor * actor;
|
||||
std::map<const ChainActor *, HeroActor *> exchangeMap;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
std::shared_mutex sync;
|
||||
|
||||
public:
|
||||
HeroExchangeMap(const HeroActor * actor, const Nullkiller * ai);
|
||||
HeroExchangeMap(const HeroActor * actor, const Nullkiller2 * ai);
|
||||
~HeroExchangeMap();
|
||||
|
||||
ExchangeResult tryExchangeNoLock(const ChainActor * other);
|
||||
@@ -121,8 +121,8 @@ public:
|
||||
std::shared_ptr<SpecialAction> exchangeAction;
|
||||
// chain flags, can be combined meaning hero exchange and so on
|
||||
|
||||
HeroActor(const CGHeroInstance * hero, HeroRole heroRole, uint64_t chainMask, const Nullkiller * ai);
|
||||
HeroActor(const ChainActor * carrier, const ChainActor * other, const HeroExchangeArmy * army, const Nullkiller * ai);
|
||||
HeroActor(const CGHeroInstance * hero, HeroRole heroRole, uint64_t chainMask, const Nullkiller2 * ai);
|
||||
HeroActor(const ChainActor * carrier, const ChainActor * other, const HeroExchangeArmy * army, const Nullkiller2 * ai);
|
||||
|
||||
protected:
|
||||
ExchangeResult tryExchangeNoLock(const ChainActor * specialActor, const ChainActor * other) const override;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "../../../lib/CRandomGenerator.h"
|
||||
#include "../../../lib/mapObjects/CQuest.h"
|
||||
#include "../../../lib/mapping/CMap.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/logging/VisualLogger.h"
|
||||
#include "Actions/QuestAction.h"
|
||||
#include "../pforeach.h"
|
||||
@@ -33,7 +33,7 @@ GraphPaths::GraphPaths()
|
||||
}
|
||||
|
||||
std::shared_ptr<SpecialAction> getCompositeAction(
|
||||
const Nullkiller * ai,
|
||||
const Nullkiller2 * ai,
|
||||
std::shared_ptr<ISpecialActionFactory> linkActionFactory,
|
||||
std::shared_ptr<SpecialAction> transitionAction)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ std::shared_ptr<SpecialAction> getCompositeAction(
|
||||
return std::make_shared<CompositeAction>(actionsArray);
|
||||
}
|
||||
|
||||
void GraphPaths::calculatePaths(const CGHeroInstance * targetHero, const Nullkiller * ai, uint8_t scanDepth)
|
||||
void GraphPaths::calculatePaths(const CGHeroInstance * targetHero, const Nullkiller2 * ai, uint8_t scanDepth)
|
||||
{
|
||||
graph.copyFrom(*ai->baseGraph);
|
||||
graph.connectHeroes(ai);
|
||||
@@ -188,7 +188,7 @@ bool GraphPathNode::tryUpdate(
|
||||
return false;
|
||||
}
|
||||
|
||||
void GraphPaths::addChainInfo(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller * ai) const
|
||||
void GraphPaths::addChainInfo(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller2 * ai) const
|
||||
{
|
||||
auto nodes = pathNodes.find(tile);
|
||||
|
||||
@@ -299,7 +299,7 @@ void GraphPaths::addChainInfo(std::vector<AIPath> & paths, int3 tile, const CGHe
|
||||
}
|
||||
}
|
||||
|
||||
void GraphPaths::quickAddChainInfoWithBlocker(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller * ai) const
|
||||
void GraphPaths::quickAddChainInfoWithBlocker(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller2 * ai) const
|
||||
{
|
||||
auto nodes = pathNodes.find(tile);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
struct GraphPathNode;
|
||||
|
||||
@@ -92,9 +92,9 @@ class GraphPaths
|
||||
|
||||
public:
|
||||
GraphPaths();
|
||||
void calculatePaths(const CGHeroInstance * targetHero, const Nullkiller * ai, uint8_t scanDepth);
|
||||
void addChainInfo(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller * ai) const;
|
||||
void quickAddChainInfoWithBlocker(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller * ai) const;
|
||||
void calculatePaths(const CGHeroInstance * targetHero, const Nullkiller2 * ai, uint8_t scanDepth);
|
||||
void addChainInfo(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller2 * ai) const;
|
||||
void quickAddChainInfoWithBlocker(std::vector<AIPath> & paths, int3 tile, const CGHeroInstance * hero, const Nullkiller2 * ai) const;
|
||||
void dumpToLog() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "AIPathfinderConfig.h"
|
||||
#include "../../../lib/CRandomGenerator.h"
|
||||
#include "../../../lib/mapping/CMap.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/logging/VisualLogger.h"
|
||||
#include "Actions/QuestAction.h"
|
||||
#include "../pforeach.h"
|
||||
@@ -44,7 +44,7 @@ void ObjectGraph::removeConnection(const int3 & from, const int3 & to)
|
||||
nodes[from].connections.erase(to);
|
||||
}
|
||||
|
||||
void ObjectGraph::updateGraph(const Nullkiller * ai)
|
||||
void ObjectGraph::updateGraph(const Nullkiller2 * ai)
|
||||
{
|
||||
auto cb = ai->cb;
|
||||
|
||||
@@ -95,7 +95,7 @@ void ObjectGraph::removeObject(const CGObjectInstance * obj)
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectGraph::connectHeroes(const Nullkiller * ai)
|
||||
void ObjectGraph::connectHeroes(const Nullkiller2 * ai)
|
||||
{
|
||||
for(auto obj : ai->memory->visitableObjs)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
class Nullkiller;
|
||||
class Nullkiller2;
|
||||
|
||||
struct ObjectLink
|
||||
{
|
||||
@@ -71,11 +71,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void updateGraph(const Nullkiller * ai);
|
||||
void updateGraph(const Nullkiller2 * ai);
|
||||
void addObject(const CGObjectInstance * obj);
|
||||
void registerJunction(const int3 & pos);
|
||||
void addVirtualBoat(const int3 & pos, const CGObjectInstance * shipyard);
|
||||
void connectHeroes(const Nullkiller * ai);
|
||||
void connectHeroes(const Nullkiller2 * ai);
|
||||
void removeObject(const CGObjectInstance * obj);
|
||||
bool tryAddConnection(const int3 & from, const int3 & to, float cost, uint64_t danger);
|
||||
void removeConnection(const int3 & from, const int3 & to);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "AIPathfinderConfig.h"
|
||||
#include "../../../lib/callback/GameRandomizer.h"
|
||||
#include "../../../lib/mapping/CMap.h"
|
||||
#include "../Engine/Nullkiller.h"
|
||||
#include "../Engine/Nullkiller2.h"
|
||||
#include "../../../lib/logging/VisualLogger.h"
|
||||
#include "Actions/QuestAction.h"
|
||||
#include "../pforeach.h"
|
||||
@@ -20,7 +20,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
ObjectGraphCalculator::ObjectGraphCalculator(ObjectGraph * target, const Nullkiller * ai)
|
||||
ObjectGraphCalculator::ObjectGraphCalculator(ObjectGraph * target, const Nullkiller2 * ai)
|
||||
:ai(ai), target(target), syncLock()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class ObjectGraphCalculator
|
||||
{
|
||||
private:
|
||||
ObjectGraph * target;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
std::mutex syncLock;
|
||||
|
||||
std::map<const CGHeroInstance *, HeroRole> actors;
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
std::vector<std::unique_ptr<CGHeroInstance>> temporaryActorHeroes;
|
||||
|
||||
public:
|
||||
ObjectGraphCalculator(ObjectGraph * target, const Nullkiller * ai);
|
||||
ObjectGraphCalculator(ObjectGraph * target, const Nullkiller2 * ai);
|
||||
void setGraphObjects();
|
||||
void calculateConnections();
|
||||
float getNeighborConnectionsCost(const int3 & pos, std::vector<AIPath> & pathCache);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "AILayerTransitionRule.h"
|
||||
#include "../../Engine/Nullkiller.h"
|
||||
#include "../../Engine/Nullkiller2.h"
|
||||
#include "../../../../lib/pathfinder/CPathfinder.h"
|
||||
#include "../../../../lib/pathfinder/TurnInfo.h"
|
||||
#include "../../../../lib/spells/ISpellMechanics.h"
|
||||
@@ -21,7 +21,7 @@ namespace AIPathfinding
|
||||
{
|
||||
AILayerTransitionRule::AILayerTransitionRule(
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
Nullkiller * ai,
|
||||
Nullkiller2 * ai,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage)
|
||||
:cb(cb), ai(ai), nodeStorage(nodeStorage)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace AIPathfinding
|
||||
{
|
||||
private:
|
||||
CPlayerSpecificInfoCallback * cb;
|
||||
Nullkiller * ai;
|
||||
Nullkiller2 * ai;
|
||||
std::map<int3, std::shared_ptr<const BuildBoatAction>> virtualBoats;
|
||||
std::shared_ptr<AINodeStorage> nodeStorage;
|
||||
std::map<const CGHeroInstance *, std::shared_ptr<const SummonBoatAction>> summonableVirtualBoats;
|
||||
@@ -35,7 +35,7 @@ namespace AIPathfinding
|
||||
public:
|
||||
AILayerTransitionRule(
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
Nullkiller * ai,
|
||||
Nullkiller2 * ai,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage);
|
||||
|
||||
virtual void process(
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace NKAI
|
||||
namespace AIPathfinding
|
||||
{
|
||||
AIMovementAfterDestinationRule::AIMovementAfterDestinationRule(
|
||||
const Nullkiller * ai,
|
||||
const Nullkiller2 * ai,
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage,
|
||||
bool allowBypassObjects)
|
||||
|
||||
@@ -23,13 +23,13 @@ namespace AIPathfinding
|
||||
{
|
||||
private:
|
||||
CPlayerSpecificInfoCallback * cb;
|
||||
const Nullkiller * ai;
|
||||
const Nullkiller2 * ai;
|
||||
std::shared_ptr<AINodeStorage> nodeStorage;
|
||||
bool allowBypassObjects;
|
||||
|
||||
public:
|
||||
AIMovementAfterDestinationRule(
|
||||
const Nullkiller * ai,
|
||||
const Nullkiller2 * ai,
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage,
|
||||
bool allowBypassObjects);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Nullkiller.h"
|
||||
#include "Engine/Nullkiller2.h"
|
||||
|
||||
namespace NKAI
|
||||
{
|
||||
@@ -26,7 +26,7 @@ void pforeachTilePos(const int3 & mapSize, TFunc fn)
|
||||
}
|
||||
|
||||
template<typename TFunc>
|
||||
void pforeachTilePaths(const int3 & mapSize, const Nullkiller * ai, TFunc fn)
|
||||
void pforeachTilePaths(const int3 & mapSize, const Nullkiller2 * ai, TFunc fn)
|
||||
{
|
||||
for(int z = 0; z < mapSize.z; ++z)
|
||||
{
|
||||
|
||||
1852
AI/Nullkiller2/AIGateway.cpp
Normal file
1852
AI/Nullkiller2/AIGateway.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user