예제 #1
0
 def test_build_gateway(self):
     with TestProtossMacro._create_macro_env() as env:
         obs = env.reset()[0]
         while True:
             act = PROTOSS_MACROS.No_op()
             if U.can_build_gateway(obs):
                 act = PROTOSS_MACROS.Build_Gateway()
             elif U.can_build_pylon(obs) and randint(0, 4) == 0:
                 act = PROTOSS_MACROS.Build_Pylon()
             obs = env.step((act, ))[0]
             if obs.last():
                 break
예제 #2
0
 def test_build_cyberneticscore(self):
     with TestProtossMacro._create_macro_env() as env:
         obs = env.reset()[0]
         while True:
             act = PROTOSS_MACROS.No_op()
             if U.can_build_cyberneticscore(obs):
                 act = PROTOSS_MACROS.Build_CyberneticsCore()
             elif U.can_build_gateway(obs) and obs._unit_counts.get(
                     units.Protoss.Gateway, 0) < 1:
                 act = PROTOSS_MACROS.Build_Gateway()
             elif U.can_build_pylon(obs) and obs._unit_counts.get(
                     units.Protoss.Pylon, 0) < 1:
                 act = PROTOSS_MACROS.Build_Pylon()
             obs = env.step((act, ))[0]
             if obs.last():
                 break
예제 #3
0
 def test_build_assimilator(self):
     with TestProtossMacro._create_macro_env() as env:
         obs = env.reset()[0]
         while True:
             act = PROTOSS_MACROS.No_op()
             if U.can_build_assimilator(obs):
                 act = PROTOSS_MACROS.Build_Assimilator()
             obs = env.step((act, ))[0]
             if obs.last():
                 break
예제 #4
0
 def test_train_probe(self):
     with TestProtossMacro._create_macro_env() as env:
         obs = env.reset()[0]
         while True:
             act = PROTOSS_MACROS.No_op()
             if U.can_train_probe(obs):
                 act = PROTOSS_MACROS.Train_Probe()
             obs = env.step((act, ))[0]
             if obs.last():
                 break
예제 #5
0
    def fill(self):
        # update feature units count info
        feature_units = self._timestep.observation.feature_units
        for unit in feature_units:
            unit_type = unit.unit_type
            if unit_type not in self._feature_units:
                self._feature_units[unit_type] = []
                self._feature_unit_counts[unit_type] = 0
            self._feature_units[unit_type].append(unit)
            self._feature_unit_counts[unit_type] += 1
            # completed units
            if int(unit.build_progress) != 100:
                continue
            if unit_type not in self._feature_units_completed:
                self._feature_units_completed[unit_type] = []
                self._feature_unit_completed_counts[unit_type] = 0
            self._feature_units_completed[unit_type].append(unit)
            self._feature_unit_completed_counts[unit_type] += 1

        # update raw units count info
        raw_units = self._timestep.observation.raw_units
        for unit in raw_units:
            if unit.alliance != 1:
                continue
            unit_type = unit.unit_type
            if not unit_type in self._raw_units:
                self._raw_units[unit_type] = []
                self._minimap_units[unit_type] = []
                self._unit_counts[unit_type] = 0
            self._raw_units[unit_type].append(unit)
            minimap_unit = copy.deepcopy(unit)
            minimap_unit.x, minimap_unit.y = U._world_tl_to_minimap_px(unit)
            self._minimap_units[unit_type].append(minimap_unit)
            self._unit_counts[unit_type] += 1
            # completed units
            if int(unit.build_progress) != 100:
                continue
            if not unit_type in self._raw_units_completed:
                self._raw_units_completed[unit_type] = []
                self._minimap_units_completed[unit_type] = []
                self._unit_completed_counts[unit_type] = 0
            self._raw_units_completed[unit_type].append(unit)
            self._minimap_units_completed[unit_type].append(minimap_unit)
            self._unit_completed_counts[unit_type] += 1