예제 #1
0
 def tech_step(self, tech_action):
     if tech_action == 0:  # nothing
         self.safe_action(C._NO_OP, 0, [])
     elif tech_action == 1:  # worker
         M.mineral_worker(self)
     elif tech_action == 2:  # pylon
         no_unit_index = U.get_unit_mask_screen(self.obs, size=2)
         pos = U.get_pos(no_unit_index)
         M.build_by_idle_worker(self, C._BUILD_PYLON_S, pos)
예제 #2
0
    def mini_step(self, action):
        if action == ProtossAction.Build_probe.value:
            M.mineral_worker(self)

        elif action == ProtossAction.Build_zealot.value:
            M.train_army(self, C._TRAIN_ZEALOT)

        elif action == ProtossAction.Build_Stalker.value:
            M.train_army(self, C._TRAIN_STALKER)

        elif action == ProtossAction.Build_pylon.value:
            no_unit_index = U.get_unit_mask_screen(self.obs, size=2)
            pos = U.get_pos(no_unit_index)
            M.build_by_idle_worker(self, C._BUILD_PYLON_S, pos)

        elif action == ProtossAction.Build_gateway.value:
            power_index = U.get_power_mask_screen(self.obs, size=5)
            pos = U.get_pos(power_index)
            M.build_by_idle_worker(self, C._BUILD_GATEWAY_S, pos)

        elif action == ProtossAction.Build_Assimilator.value:
            if self._gases is not None:
                #U.find_gas_pos(self.obs, 1)
                gas_1 = self._gases[0]
                gas_2 = self._gases[1]

                if gas_1 is not None and not U.is_assimilator_on_gas(
                        self.obs, gas_1):
                    gas_1_pos = T.world_to_screen_pos(self.env.game_info,
                                                      gas_1.pos, self.obs)
                    M.build_by_idle_worker(self, C._BUILD_ASSIMILATOR_S,
                                           gas_1_pos)

                elif gas_2 is not None and not U.is_assimilator_on_gas(
                        self.obs, gas_2):
                    gas_2_pos = T.world_to_screen_pos(self.env.game_info,
                                                      gas_2.pos, self.obs)
                    M.build_by_idle_worker(self, C._BUILD_ASSIMILATOR_S,
                                           gas_2_pos)

        elif action == ProtossAction.Build_CyberneticsCore.value:
            power_index = U.get_power_mask_screen(self.obs, size=3)
            pos = U.get_pos(power_index)
            M.build_by_idle_worker(self, C._BUILD_CYBER_S, pos)

        elif action == ProtossAction.Attack.value:
            M.attack_step(self)

        elif action == ProtossAction.Retreat.value:
            M.retreat_step(self)

        elif action == ProtossAction.Do_nothing.value:
            self.safe_action(C._NO_OP, 0, [])
예제 #3
0
 def pop_step(self, pop_action):
     # to execute a pop_action
     # [ mineral_probe, zealot, stalker]
     #print('pop_action', pop_action)
     if pop_action == 0:  # mineral_probe
         M.mineral_worker(self)
         # print('mineral_worker')
     elif pop_action == 1:  # zealot
         M.train_army(self, C._TRAIN_ZEALOT)
         # print('_TRAIN_ZEALOT')
     elif pop_action == 2:  # stalker
         M.train_army(self, C._TRAIN_STALKER)
         # print('_TRAIN_STALKER')
     else:
         self.safe_action(C._NO_OP, 0, [])
예제 #4
0
 def mini_step(self, action):
     if action == ProtossAction.Build_worker.value:
         M.mineral_worker(self)
     elif action == ProtossAction.Build_zealot.value:
         M.train_army(self, C._TRAIN_ZEALOT)
     elif action == ProtossAction.Build_pylon.value:
         no_unit_index = U.get_unit_mask_screen(self.obs, size=2)
         pos = U.get_pos(no_unit_index)
         M.build_by_idle_worker(self, C._BUILD_PYLON_S, pos)
     elif action == ProtossAction.Build_gateway.value:
         power_index = U.get_power_mask_screen(self.obs, size=5)
         pos = U.get_pos(power_index)
         M.build_by_idle_worker(self, C._BUILD_GATEWAY_S, pos)
     elif action == ProtossAction.Attack.value:
         M.attack_step(self)
     elif action == ProtossAction.Defend.value:
         M.retreat_step(self)
     elif action == ProtossAction.Build_sub_base.value:
         self.safe_action(C._NO_OP, 0, [])
     elif action == ProtossAction.Build_cannon.value:
         self.safe_action(C._NO_OP, 0, [])
     else:
         self.safe_action(C._NO_OP, 0, [])