Преглед на файлове

Sorting tasks after buildPlan

Tasks need to be sorted again after buildPlan as otherwise the correct order isn't guaranteed. This led to inconsistent behavior by the AI.
Xilmi преди 1 година
родител
ревизия
734f815e67
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      AI/Nullkiller/Engine/Nullkiller.cpp

+ 5 - 0
AI/Nullkiller/Engine/Nullkiller.cpp

@@ -399,6 +399,11 @@ void Nullkiller::makeTurn()
 
 		auto selectedTasks = buildPlan(bestTasks);
 
+		std::sort(selectedTasks.begin(), selectedTasks.end(), [](const TTask& a, const TTask& b) 
+		{
+			return a->priority > b->priority;
+		});
+
 		logAi->debug("Decision madel in %ld", timeElapsed(start));
 
 		if(selectedTasks.empty())