mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
NullkillerAI: Added movement cost by hero role. New priority engine looks more or less stable.
This commit is contained in:
parent
eea5cb7f0b
commit
af9261d428
@ -34,6 +34,13 @@ const int ALLOWED_ROAMING_HEROES = 8;
|
||||
extern const float SAFE_ATTACK_CONSTANT;
|
||||
extern const int GOLD_RESERVE;
|
||||
|
||||
enum HeroRole
|
||||
{
|
||||
MAIN,
|
||||
|
||||
SCOUT
|
||||
};
|
||||
|
||||
//provisional class for AI to store a reference to an owned hero object
|
||||
//checks if it's valid on access, should be used in place of const CGHeroInstance*
|
||||
|
||||
|
@ -53,7 +53,8 @@ void PriorityEvaluator::initVisitTile()
|
||||
armyLossPersentageVariable = engine->getInputVariable("armyLoss");
|
||||
heroRoleVariable = engine->getInputVariable("heroRole");
|
||||
dangerVariable = engine->getInputVariable("danger");
|
||||
turnDistanceVariable = engine->getInputVariable("turnDistance");
|
||||
mainTurnDistanceVariable = engine->getInputVariable("mainTurnDistance");
|
||||
scoutTurnDistanceVariable = engine->getInputVariable("scoutTurnDistance");
|
||||
goldRewardVariable = engine->getInputVariable("goldReward");
|
||||
armyRewardVariable = engine->getInputVariable("armyReward");
|
||||
skillRewardVariable = engine->getInputVariable("skillReward");
|
||||
@ -380,7 +381,8 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task)
|
||||
{
|
||||
armyLossPersentageVariable->setValue(armyLossPersentage);
|
||||
heroRoleVariable->setValue(heroRole);
|
||||
turnDistanceVariable->setValue(task->evaluationContext.movementCost);
|
||||
mainTurnDistanceVariable->setValue(task->evaluationContext.movementCostByRole[HeroRole::MAIN]);
|
||||
scoutTurnDistanceVariable->setValue(task->evaluationContext.movementCostByRole[HeroRole::SCOUT]);
|
||||
goldRewardVariable->setValue(goldReward);
|
||||
armyRewardVariable->setValue(armyReward);
|
||||
skillRewardVariable->setValue(skillReward);
|
||||
|
@ -30,7 +30,8 @@ private:
|
||||
fl::Engine * engine;
|
||||
fl::InputVariable * armyLossPersentageVariable;
|
||||
fl::InputVariable * heroRoleVariable;
|
||||
fl::InputVariable * turnDistanceVariable;
|
||||
fl::InputVariable * mainTurnDistanceVariable;
|
||||
fl::InputVariable * scoutTurnDistanceVariable;
|
||||
fl::InputVariable * goldRewardVariable;
|
||||
fl::InputVariable * armyRewardVariable;
|
||||
fl::InputVariable * dangerVariable;
|
||||
|
@ -95,6 +95,8 @@ namespace Goals
|
||||
struct DLL_EXPORT EvaluationContext
|
||||
{
|
||||
float movementCost;
|
||||
std::map<HeroRole, float> movementCostByRole;
|
||||
float scoutMovementCost;
|
||||
int manaCost;
|
||||
uint64_t danger;
|
||||
float closestWayRatio;
|
||||
@ -107,7 +109,8 @@ namespace Goals
|
||||
danger(0),
|
||||
closestWayRatio(1),
|
||||
armyLoss(0),
|
||||
heroStrength(0)
|
||||
heroStrength(0),
|
||||
movementCostByRole()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -30,9 +30,17 @@ ExecuteHeroChain::ExecuteHeroChain(const AIPath & path, const CGObjectInstance *
|
||||
evaluationContext.movementCost = path.movementCost();
|
||||
evaluationContext.armyLoss = path.getTotalArmyLoss();
|
||||
evaluationContext.heroStrength = path.getHeroStrength();
|
||||
|
||||
hero = path.targetHero;
|
||||
tile = path.targetTile();
|
||||
|
||||
for(auto & node : path.nodes)
|
||||
{
|
||||
auto role = ai->ah->getHeroRole(node.targetHero);
|
||||
|
||||
evaluationContext.movementCostByRole[role] += node.cost;
|
||||
}
|
||||
|
||||
if(obj)
|
||||
{
|
||||
objid = obj->id.getNum();
|
||||
|
@ -18,13 +18,6 @@
|
||||
#include "../../lib/CBuildingHandler.h"
|
||||
#include "VCAI.h"
|
||||
|
||||
enum HeroRole
|
||||
{
|
||||
MAIN,
|
||||
|
||||
SCOUT
|
||||
};
|
||||
|
||||
class DLL_EXPORT IHeroManager //: public: IAbstractManager
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user