Пример #1
0
    def run_independently(self, terminate_request_event):
        self.init_py4j_stuff()

        while not terminate_request_event.is_set():
            # Continuously make sure the java interface is started and the bot is registered.
            # These functions can be called repeatedly without any bad effects.
            # This is useful for re-engaging the java server if it gets restarted during development.
            try:
                self.javaInterface.ensureStarted(
                    game_interface.get_dll_location())
                self.javaInterface.ensureBotRegistered(self.index, self.name,
                                                       self.team)
            except Exception as e:
                self.logger.warn(str(e))
            time.sleep(1)
    def initialize_agent(self):

        initialized = False

        while not initialized:
            # Continuously make sure the java interface is started and the bot is registered.
            # These functions can be called repeatedly without any bad effects.
            # This is useful for re-engaging the java server if it gets restarted during development.
            try:
                self.init_py4j_stuff()
                self.javaInterface.ensureDllInitialized(game_interface.get_dll_location())
                self.javaInterface.registerPyAdapter(self.index, self.name, self.team)
                initialized = True
            except Exception as e:
                self.logger.warn(str(e))
                time.sleep(1)