You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When initializing Unit objects, one would probably add attributes to it later, e.g. unit.is_scout: bool or unit.mining_at_mineral_patch: int to have some sort of persistent data.
This can only be done by extending the Unit class (either by modifying its file or inheriting) and making the Unit object persistent (either by actually making it persistent, or just updating its unit._proto data and invalidating all cache https://docs.python.org/3/library/functools.html#functools.cached_property ).
Instead of invalidating cache it can make sense to convert @cached_property back to @property for example for unit.orders for attributes that may change over multiple frames.
Alternatively the is_scout function can be a property that accesses data from the persistent bot object instead.
For example
When initializing
Unit
objects, one would probably add attributes to it later, e.g.unit.is_scout: bool
orunit.mining_at_mineral_patch: int
to have some sort of persistent data.This can only be done by extending the Unit class (either by modifying its file or inheriting) and making the Unit object persistent (either by actually making it persistent, or just updating its
unit._proto
data and invalidating all cache https://docs.python.org/3/library/functools.html#functools.cached_property ).Instead of invalidating cache it can make sense to convert
@cached_property
back to@property
for example forunit.orders
for attributes that may change over multiple frames.Alternatively the
is_scout
function can be a property that accesses data from the persistent bot object instead.For example
A solution may be to allow bot authors to set a custom class for
Unit
objects to be initialized with inpython-sc2/sc2/bot_ai_internal.py
Line 566 in 76e4a43
as long as they inherit from
Unit
class.The text was updated successfully, but these errors were encountered: