Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3605 closed enhancement (fixed)

Improve the findNewTarget UnitAI function

Reported by: mimo Owned by: mimo
Priority: Should Have Milestone: Alpha 19
Component: UI & Simulation Keywords:
Cc: Patch:

Description

When lots of units are involved, this function is really slow, mainly due to the fact that AttackEntitiesByPreference starts by checking all units in range to know if they canAttack, then sort them by preference, and then try to attack in the found order. The sort is in fact useless as units are already sorted by distance, and we only need to classify them by distance. As the initial canAttack check is quite long, it can be omitted first and only done when units are effectively tried to attack. This is done in the attached patch which reduces the time to perform findNewtarget in "Demo Combat Huge" by a factor 4, while in this map it initially represented up to 40% of the simulation time.

Attachments (1)

attackByPreference.patch (1.4 KB ) - added by mimo 8 years ago.

Download all attachments as: .zip

Change History (4)

by mimo, 8 years ago

Attachment: attackByPreference.patch added

comment:2 by mimo, 8 years ago

Owner: set to mimo
Resolution: fixed
Status: newclosed

In 17264:

optimize the finding of new target (no changes on the output) when lots of units involved, fixes #3605

comment:3 by mimo, 8 years ago

Milestone: BacklogAlpha 19
Note: See TracTickets for help on using tickets.