コード例 #1
0
    def tech_step(self, tech_action):
        # to execute a tech_action
        # [pylon, gas1, gas2, gateway, cyber]

        if tech_action == 0:  # 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)

        elif tech_action == 1 and not U.find_gas(self.obs, 1):  # gas_1
            gas_1 = U.find_gas_pos(self.obs, 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 tech_action == 1 and not U.find_gas(self.obs, 2):  # gas_2
            gas_2 = U.find_gas_pos(self.obs, 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 tech_action == 2:  # gateway
            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 tech_action == 3:  # cyber
            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)

        else:
            self.safe_action(C._NO_OP, 0, [])
コード例 #2
0
ファイル: multi_agent.py プロジェクト: liuruoze/Thought-SC2
 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)
コード例 #3
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, [])
コード例 #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, [])