Merge pull request #548 from yapb/issue-542

fix: node selection when there's too less important nodes (fix #542)
This commit is contained in:
jeefo 2024-03-29 00:21:59 +03:00 committed by GitHub
commit 8a22f03640
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -383,19 +383,30 @@ void Bot::postprocessGoals (const IntArray &goals, int result[]) {
} }
return isOccupiedNode (index); return isOccupiedNode (index);
}; };
static IntArray resulting {};
resulting.clear ();
// too less to choice from just return all the goals // too less to choice from, this is usually waypointer mistake, number of def/offensive points count should be minimum of 4
if (goals.length () < 4) { if (goals.length () < 4) {
for (size_t i = 0; i < goals.length (); ++i) { auto refill = [] (const IntArray &data) {
result[i] = goals[i]; if (!data.empty ()) {
resulting.insert (0, data);
} }
return; };
// combine defensive and offensive and goals together to give a chance to proceed
refill (graph.m_ctPoints);
refill (graph.m_terrorPoints);
refill (graph.m_goalPoints);
}
else {
resulting.insert (0, goals);
} }
for (int index = 0; index < 4; ++index) { for (int index = 0; index < 4; ++index) {
const auto goal = goals.random (); const auto goal = resulting.random ();
if (recurseCount <= cr::max (4, goals.length <int> ()) && isRecentOrHistorical (goal)) { if (recurseCount <= cr::max (4, resulting.length <int> ()) && isRecentOrHistorical (goal)) {
if (index > 0) { if (index > 0) {
index--; index--;
} }