Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#2156 closed defect (fixed)

[PATCH] Improve UnitAI range query performance

Reported by: historic_bruno Owned by: dumbo
Priority: Must Have Milestone: Alpha 16
Component: UI & Simulation Keywords: simple patch
Cc: Patch:

Description

Currently, citizen soldiers' UnitAI can have two active range queries: one for finding attackable enemy entities, the other for finding gaia entities capable of attack (see SetupGaiaRangeQuery). This is a waste because it basically doubles the amount of work CmpRangeManager must do for those units. Instead, we could combine these into a single range query for gaia+enemies, then filter out non-attacking gaia entities from the query results in UnitAI.

Of course, it should be profiled before and after the change to ensure an improvement.

Attachments (2)

2156_unitAI_range_queries.patch (6.5 KB ) - added by dumbo 10 years ago.
[PATCH] for #2156 – UnitAI.js range queries, NOT profiled
2156_unitAI_range_queries_testpass.patch (7.6 KB ) - added by dumbo 10 years ago.
now passes a test also. thanks for sanderd

Download all attachments as: .zip

Change History (11)

comment:1 by sanderd17, 11 years ago

There's a similar case for BuildingAI

comment:2 by leper, 10 years ago

Keywords: simple added
Milestone: Alpha 15Alpha 16

by dumbo, 10 years ago

[PATCH] for #2156 – UnitAI.js range queries, NOT profiled

comment:3 by sanderd17, 10 years ago

The patch looks good, but you broke the tests though. (the test binary is in the same directory as the pyrogenesis binary, run it in a terminal to see where it breaks).

Btw, while you're on it. It might be nice to prefer attacking units over animals (in the AttackEntitiesByPreference method).

Also, see this: SubmittingPatches

Last edited 10 years ago by sanderd17 (previous) (diff)

comment:4 by dumbo, 10 years ago

Owner: set to dumbo

comment:5 by Josh, 10 years ago

Keywords: patch added
Summary: Improve UnitAI range query performance[PATCH] Improve UnitAI range query performance

by dumbo, 10 years ago

now passes a test also. thanks for sanderd

comment:6 by dumbo, 10 years ago

Keywords: review added
Resolution: fixed
Status: newclosed

comment:8 by sanderd17, 10 years ago

In 14473:

include gaia range query of UnitAI in general range query. Fixes #2156. Patch by dumbo

comment:9 by leper, 10 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.