From 734f815e67659ab64339e67600b80e3bd03bf2bc Mon Sep 17 00:00:00 2001 From: Xilmi Date: Sun, 7 Jul 2024 15:12:05 +0200 Subject: [PATCH] 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. --- AI/Nullkiller/Engine/Nullkiller.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AI/Nullkiller/Engine/Nullkiller.cpp b/AI/Nullkiller/Engine/Nullkiller.cpp index fa15363f6..81a144b72 100644 --- a/AI/Nullkiller/Engine/Nullkiller.cpp +++ b/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())