def step(self, obs):
        super(Overmind, self).step(obs)

        if (not self.loaded):
            self.loaded = True
            self.homeHatch = self.get_buildings(obs, units.Zerg.Hatchery)[0]
            self.model = ks.models.load_model(
                "C:\\Users\\Charlie\Models\\Conv2D-noobs - 1st Gen")
            return FUNCTIONS.move_camera(
                [const.MiniMapSize().x / 2,
                 const.MiniMapSize().y / 2])

        # If nothing to macro
        # if obs.observation.player['food_army'] < 10:
        #     function = self.macro(obs)
        #     print(function)
        #     return function

        T = Translator()

        tFeatureLayers = T.translate_feature_layers(
            T.crop_feature_layers(obs.observation.feature_screen[0],
                                  obs.observation.feature_screen,
                                  const.ScreenSize().x,
                                  const.ScreenSize().y))

        featureLayers = (np.moveaxis((np.array(tFeatureLayers)), 0,
                                     2)).reshape(-1,
                                                 const.ScreenSize().x,
                                                 const.ScreenSize().y, 12)
        prediction = self.model.predict(featureLayers)[0]
        action = translate(obs, prediction)
        print(action[0])
        for pred in prediction:
            print(pred)
        if (action[0] in obs.observation.available_actions):
            return actions.FunctionCall(action[0], action[1:])
        else:
            print("No-op, Switching to Macro:")
            function = self.macro(obs)
            print(function)
            return function
示例#2
0
文件: Action.py 项目: arturblch/Agent
 def moveCamera(x1, y1):
     action = Action()
     action.addCommand(FUNCTIONS.move_camera([x1, y1]))
     return action