Skip to content
Matti Bragge edited this page Apr 7, 2020 · 1 revision

Unit cache is designed for making Sharpy run faster.

instead of

self.ai.structures(UnitTypeId.NEXUS) 
# or 
self.ai.units(UnitTypeId.ZEALOT)

It's recommented to use the unit cache manager

self.cache.own(UnitTypeId.NEXUS)
# or
self.knowledge.unit_cache.own(UnitTypeId.NEXUS)

self.cache.enemy for enemy units.

self.cache.by_tag for getting units by their tags. Works for both own and enemy units.

own_in_range and enemy_in_range are also available and use scipy cKDTree to get units around a specified point.

All functions in cache manager return both units and buildings.

Clone this wiki locally