mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Enum for PriorityTiers
In order to not confuse PriorityTiers, especially after adding new ones, now using an enum to identify them.
This commit is contained in:
@@ -467,7 +467,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
|
||||
heroesProcessed.insert(path.targetHero);
|
||||
|
||||
float priority = priorityEvaluator->evaluate(Goals::sptr(Goals::ExecuteHeroChain(path, obj)), 5);
|
||||
float priority = priorityEvaluator->evaluate(Goals::sptr(Goals::ExecuteHeroChain(path, obj)), PriorityEvaluator::PriorityTier::HUNTER_GATHER);
|
||||
|
||||
if(ai->settings->isUseFuzzy() && priority < MIN_PRIORITY)
|
||||
continue;
|
||||
@@ -490,7 +490,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
|
||||
heroesProcessed.insert(path.targetHero);
|
||||
|
||||
float priority = priorityEvaluator->evaluate(Goals::sptr(Goals::ExecuteHeroChain(path, obj)), 5);
|
||||
float priority = priorityEvaluator->evaluate(Goals::sptr(Goals::ExecuteHeroChain(path, obj)), PriorityEvaluator::PriorityTier::HUNTER_GATHER);
|
||||
|
||||
if (ai->settings->isUseFuzzy() && priority < MIN_PRIORITY)
|
||||
continue;
|
||||
|
||||
@@ -180,7 +180,7 @@ Goals::TTaskVec Nullkiller::buildPlan(TGoalVec & tasks, int priorityTier) const
|
||||
for(size_t i = r.begin(); i != r.end(); i++)
|
||||
{
|
||||
auto task = tasks[i];
|
||||
if (task->asTask()->priority <= 0 || priorityTier != 0)
|
||||
if (task->asTask()->priority <= 0 || priorityTier != PriorityEvaluator::PriorityTier::BUILDINGS)
|
||||
task->asTask()->priority = evaluator->evaluate(task, priorityTier);
|
||||
}
|
||||
});
|
||||
@@ -385,7 +385,7 @@ void Nullkiller::makeTurn()
|
||||
|
||||
if(bestTask->priority > 0)
|
||||
{
|
||||
logAi->info("Pass %d: Performing task %s with prio: %d", bestTask->toString(), bestTask->priority);
|
||||
logAi->info("Pass %d: Performing task %s with prio: %d", i, bestTask->toString(), bestTask->priority);
|
||||
if(!executeTask(bestTask))
|
||||
return;
|
||||
|
||||
@@ -408,7 +408,7 @@ void Nullkiller::makeTurn()
|
||||
|
||||
TTaskVec selectedTasks;
|
||||
int prioOfTask = 0;
|
||||
for (int prio = 1; prio <= 6; ++prio)
|
||||
for (int prio = PriorityEvaluator::PriorityTier::INSTAKILL; prio <= PriorityEvaluator::PriorityTier::DEFEND; ++prio)
|
||||
{
|
||||
prioOfTask = prio;
|
||||
selectedTasks = buildPlan(bestTasks, prio);
|
||||
|
||||
@@ -1398,7 +1398,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
|
||||
switch (priorityTier)
|
||||
{
|
||||
case 1: //Take towns / kill heroes in immediate reach
|
||||
case PriorityTier::INSTAKILL: //Take towns / kill heroes in immediate reach
|
||||
{
|
||||
if (evaluationContext.turn > 0)
|
||||
return 0;
|
||||
@@ -1413,14 +1413,14 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
score /= evaluationContext.movementCost;
|
||||
break;
|
||||
}
|
||||
case 2: //Defend immediately threatened towns
|
||||
case PriorityTier::INSTADEFEND: //Defend immediately threatened towns
|
||||
{
|
||||
if (evaluationContext.isDefend && evaluationContext.threatTurns == 0 && evaluationContext.turn == 0)
|
||||
score = evaluationContext.armyInvolvement;
|
||||
score *= evaluationContext.closestWayRatio;
|
||||
break;
|
||||
}
|
||||
case 3: //Take towns / kill heroes that are further away
|
||||
case PriorityTier::KILL: //Take towns / kill heroes that are further away
|
||||
{
|
||||
if (evaluationContext.conquestValue > 0)
|
||||
score = 1000;
|
||||
@@ -1433,7 +1433,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
score /= evaluationContext.movementCost;
|
||||
break;
|
||||
}
|
||||
case 4: //Collect unguarded stuff
|
||||
case PriorityTier::GATHER: //Collect unguarded stuff
|
||||
{
|
||||
if (evaluationContext.enemyHeroDangerRatio > 1)
|
||||
return 0;
|
||||
@@ -1463,7 +1463,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
score /= evaluationContext.movementCost;
|
||||
break;
|
||||
}
|
||||
case 5: //Collect guarded stuff
|
||||
case PriorityTier::HUNTER_GATHER: //Collect guarded stuff
|
||||
{
|
||||
if (evaluationContext.enemyHeroDangerRatio > 1 && !evaluationContext.isDefend)
|
||||
return 0;
|
||||
@@ -1489,7 +1489,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: //Defend whatever if nothing else is to do
|
||||
case PriorityTier::DEFEND: //Defend whatever if nothing else is to do
|
||||
{
|
||||
if (evaluationContext.enemyHeroDangerRatio > 1 && evaluationContext.isExchange)
|
||||
return 0;
|
||||
@@ -1499,7 +1499,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
score /= (evaluationContext.turn + 1);
|
||||
break;
|
||||
}
|
||||
case 0: //For buildings and buying army
|
||||
case PriorityTier::BUILDINGS: //For buildings and buying army
|
||||
{
|
||||
if (maxWillingToLose - evaluationContext.armyLossPersentage < 0)
|
||||
return 0;
|
||||
|
||||
@@ -104,7 +104,18 @@ public:
|
||||
~PriorityEvaluator();
|
||||
void initVisitTile();
|
||||
|
||||
float evaluate(Goals::TSubgoal task, int priorityTier = 0);
|
||||
float evaluate(Goals::TSubgoal task, int priorityTier = BUILDINGS);
|
||||
|
||||
enum PriorityTier : int32_t
|
||||
{
|
||||
BUILDINGS = 0,
|
||||
INSTAKILL,
|
||||
INSTADEFEND,
|
||||
KILL,
|
||||
GATHER,
|
||||
HUNTER_GATHER,
|
||||
DEFEND
|
||||
};
|
||||
|
||||
private:
|
||||
const Nullkiller * ai;
|
||||
|
||||
Reference in New Issue
Block a user