diff --git a/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp b/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp index 8d318badf..7e46dc713 100644 --- a/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp +++ b/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp @@ -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; diff --git a/AI/Nullkiller/Engine/Nullkiller.cpp b/AI/Nullkiller/Engine/Nullkiller.cpp index 9984dbf51..bc6dae208 100644 --- a/AI/Nullkiller/Engine/Nullkiller.cpp +++ b/AI/Nullkiller/Engine/Nullkiller.cpp @@ -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); diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index d898ae1b8..51c2ac804 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -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; diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.h b/AI/Nullkiller/Engine/PriorityEvaluator.h index c6cef4960..771a913e3 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.h +++ b/AI/Nullkiller/Engine/PriorityEvaluator.h @@ -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;