Fix crash when enemy in sensor tower range + support destructible rocksu
from .units import Units
from .power_source import PsionicMatrix
+from .pixel_map import PixelMap
class Common(object):
ATTRIBUTES = [
@@ -20,10 +21,19 @@ class Common(object):
class GameState(object):
def __init__(self, observation, game_data):
self.common = Common(observation.observation.player_common)
- self.units = Units.from_proto(observation.observation.raw_data.units, game_data)
self.psionic_matrix = PsionicMatrix.from_proto(observation.observation.raw_data.player.power_sources)
self.game_loop = observation.observation.game_loop
+ destructables = [x for x in observation.observation.raw_data.units if x.alliance == 3 and x.radius > 1.5] # all destructable rocks except the one below the main base ramps
+ self.destructables = Units.from_proto(destructables, game_data)
+
+ # fix for enemy units detected by sensor tower
+ visibleUnits, hiddenUnits = [], []
+ for u in observation.observation.raw_data.units:
+ hiddenUnits.append(u) if u.is_blip else visibleUnits.append(u)
+ self.units = Units.from_proto(visibleUnits, game_data)
+ # self.blips = Units.from_proto(hiddenUnits, game_data) # TODO: fix me
+
@property
def mineral_field(self):
return self.units.mineral_field
