mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Nullkiller: update / fix build, core changes required for Nullkiller AI
This commit is contained in:
committed by
Andrii Danylchenko
parent
b4241670ba
commit
3fa7e0976f
@@ -26,7 +26,7 @@ AINodeStorage::AINodeStorage(const int3 & Sizes)
|
||||
|
||||
AINodeStorage::~AINodeStorage() = default;
|
||||
|
||||
void AINodeStorage::initialize(const PathfinderOptions & options, const CGameState * gs, const CGHeroInstance * hero)
|
||||
void AINodeStorage::initialize(const PathfinderOptions & options, const CGameState * gs)
|
||||
{
|
||||
//TODO: fix this code duplication with NodeStorage::initialize, problem is to keep `resetTile` inline
|
||||
|
||||
@@ -109,7 +109,7 @@ boost::optional<AIPathNode *> AINodeStorage::getOrCreateNode(const int3 & pos, c
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
CGPathNode * AINodeStorage::getInitialNode()
|
||||
std::vector<CGPathNode *> AINodeStorage::getInitialNodes()
|
||||
{
|
||||
auto hpos = hero->getPosition(false);
|
||||
auto initialNode =
|
||||
@@ -121,7 +121,7 @@ CGPathNode * AINodeStorage::getInitialNode()
|
||||
initialNode->danger = 0;
|
||||
initialNode->setCost(0.0);
|
||||
|
||||
return initialNode;
|
||||
return {initialNode};
|
||||
}
|
||||
|
||||
void AINodeStorage::resetTile(const int3 & coord, EPathfindingLayer layer, CGPathNode::EAccessibility accessibility)
|
||||
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
AINodeStorage(const int3 & sizes);
|
||||
~AINodeStorage();
|
||||
|
||||
void initialize(const PathfinderOptions & options, const CGameState * gs, const CGHeroInstance * hero) override;
|
||||
void initialize(const PathfinderOptions & options, const CGameState * gs) override;
|
||||
|
||||
virtual CGPathNode * getInitialNode() override;
|
||||
virtual std::vector<CGPathNode *> getInitialNodes() override;
|
||||
|
||||
virtual std::vector<CGPathNode *> calculateNeighbours(
|
||||
const PathNodeInfo & source,
|
||||
@@ -106,11 +106,7 @@ public:
|
||||
bool isTileAccessible(const int3 & pos, const EPathfindingLayer layer) const;
|
||||
|
||||
void setHero(HeroPtr heroPtr, const VCAI * ai);
|
||||
|
||||
const CGHeroInstance * getHero() const
|
||||
{
|
||||
return hero;
|
||||
}
|
||||
const CGHeroInstance * getHero() const { return hero; }
|
||||
|
||||
uint64_t evaluateDanger(const int3 & tile) const
|
||||
{
|
||||
|
||||
@@ -56,8 +56,8 @@ void AIPathfinder::updatePaths(std::vector<HeroPtr> heroes)
|
||||
auto calculatePaths = [&](const CGHeroInstance * hero, std::shared_ptr<AIPathfinding::AIPathfinderConfig> config)
|
||||
{
|
||||
logAi->debug("Recalculate paths for %s", hero->name);
|
||||
|
||||
cb->calculatePaths(config, hero);
|
||||
|
||||
cb->calculatePaths(config);
|
||||
};
|
||||
|
||||
std::vector<CThreadHelper::Task> calculationTasks;
|
||||
|
||||
@@ -37,7 +37,17 @@ namespace AIPathfinding
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
VCAI * ai,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage)
|
||||
:PathfinderConfig(nodeStorage, makeRuleset(cb, ai, nodeStorage))
|
||||
:PathfinderConfig(nodeStorage, makeRuleset(cb, ai, nodeStorage)), hero(nodeStorage->getHero())
|
||||
{
|
||||
}
|
||||
|
||||
CPathfinderHelper * AIPathfinderConfig::getOrCreatePathfinderHelper(const PathNodeInfo & source, CGameState * gs)
|
||||
{
|
||||
if(!helper)
|
||||
{
|
||||
helper.reset(new CPathfinderHelper(gs, hero, options));
|
||||
}
|
||||
|
||||
return helper.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,16 @@ namespace AIPathfinding
|
||||
{
|
||||
class AIPathfinderConfig : public PathfinderConfig
|
||||
{
|
||||
private:
|
||||
const CGHeroInstance * hero;
|
||||
std::unique_ptr<CPathfinderHelper> helper;
|
||||
|
||||
public:
|
||||
AIPathfinderConfig(
|
||||
CPlayerSpecificInfoCallback * cb,
|
||||
VCAI * ai,
|
||||
std::shared_ptr<AINodeStorage> nodeStorage);
|
||||
|
||||
virtual CPathfinderHelper * getOrCreatePathfinderHelper(const PathNodeInfo & source, CGameState * gs) override;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user