示例#1
0
    def run_agent(terminate_event, callback_event, reload_request, config_file, name, team, index, python_file,
                  agent_telemetry_queue, agent_state_queue, queue_holder, match_config: MatchConfig):

        agent_class_wrapper = import_agent(python_file)
        bm = BotManagerStruct(terminate_event, callback_event, reload_request, config_file, name, team, index,
                                agent_class_wrapper, agent_telemetry_queue, queue_holder, match_config, agent_state_queue)
        bm.run()
示例#2
0
def run_bot(agent_class: Type[StandaloneBot]):
    config = StandaloneBotConfig(sys.argv)
    python_file = inspect.getfile(agent_class)

    config_obj = agent_class.base_create_agent_configurations()
    bundle = None
    if config.config_file is not None:
        # If the config file was not passed, then the bot will miss out on any custom configuration,
        # tick rate preference, etc.
        bundle = get_bot_config_bundle(
            Path(python_file).parent / config.config_file)
        config_obj.parse_file(bundle.config_obj,
                              config_directory=bundle.config_directory)

    spawn_id = config.spawn_id
    player_index = config.player_index
    team = config.team
    name = config.name

    if config.is_missing_args:
        # This process must not have been created by the RLBot framework, so this is probably
        # a developer doing some testing who did not pass all the params. Take it upon ourselves
        # to fire up the game if necessary.
        print(
            f'############################################################################################'
        )
        print(
            f'Args are missing, so we will assume this is a dev workflow and insert the bot into the game!'
        )
        print(
            f'############################################################################################'
        )
        test_spawner = TestSpawner(Path(python_file), config, bundle)
        test_spawner.spawn_bot()
        spawn_id = test_spawner.spawn_id
        player_index = test_spawner.player_index
        team = test_spawner.team
        name = test_spawner.name

    agent_class_wrapper = ExternalClassWrapper(python_file, StandaloneBot)

    # Pass in dummy objects for mp.Event, mp.Queue. We will not support that
    # functionality for standalone bots; it's generally unused anyway.
    bot_manager = BotManagerStruct(terminate_request_event=mp.Event(),
                                   termination_complete_event=mp.Event(),
                                   reload_request_event=mp.Event(),
                                   bot_configuration=config_obj,
                                   name=name,
                                   team=team,
                                   index=player_index,
                                   agent_class_wrapper=agent_class_wrapper,
                                   agent_metadata_queue=mp.Queue(),
                                   match_config=None,
                                   matchcomms_root=config.matchcomms_url,
                                   spawn_id=spawn_id)
    bot_manager.run()
示例#3
0
    def run_agent(terminate_event, callback_event, reload_request,
                  bundle: BotConfigBundle, name, team, index, python_file,
                  agent_telemetry_queue, match_config: MatchConfig,
                  matchcomms_root: URL, spawn_id: str):

        agent_class_wrapper = import_agent(python_file)
        config_file = agent_class_wrapper.get_loaded_class(
        ).base_create_agent_configurations()
        config_file.parse_file(bundle.config_obj,
                               config_directory=bundle.config_directory)

        if hasattr(agent_class_wrapper.get_loaded_class(),
                   "run_independently"):
            bm = BotManagerIndependent(terminate_event, callback_event,
                                       reload_request, config_file, name, team,
                                       index, agent_class_wrapper,
                                       agent_telemetry_queue, match_config,
                                       matchcomms_root, spawn_id)
        elif hasattr(agent_class_wrapper.get_loaded_class(),
                     "get_output_flatbuffer"):
            bm = BotManagerFlatbuffer(terminate_event, callback_event,
                                      reload_request, config_file, name, team,
                                      index, agent_class_wrapper,
                                      agent_telemetry_queue, match_config,
                                      matchcomms_root, spawn_id)
        else:
            bm = BotManagerStruct(terminate_event, callback_event,
                                  reload_request, config_file, name, team,
                                  index, agent_class_wrapper,
                                  agent_telemetry_queue, match_config,
                                  matchcomms_root, spawn_id)
        bm.run()
示例#4
0
    def run_agent(terminate_event, callback_event, reload_request, config_file,
                  name, team, index, python_file, agent_telemetry_queue,
                  queue_holder, match_config: MatchConfig):

        agent_class_wrapper = import_agent(python_file)

        if hasattr(agent_class_wrapper.get_loaded_class(),
                   "run_independently"):
            bm = BotManagerIndependent(terminate_event, callback_event,
                                       reload_request, config_file, name, team,
                                       index, agent_class_wrapper,
                                       agent_telemetry_queue, queue_holder,
                                       match_config)
        elif hasattr(agent_class_wrapper.get_loaded_class(),
                     "get_output_flatbuffer"):
            bm = BotManagerFlatbuffer(terminate_event, callback_event,
                                      reload_request, config_file, name, team,
                                      index, agent_class_wrapper,
                                      agent_telemetry_queue, queue_holder,
                                      match_config)
        else:
            bm = BotManagerStruct(terminate_event, callback_event,
                                  reload_request, config_file, name, team,
                                  index, agent_class_wrapper,
                                  agent_telemetry_queue, queue_holder,
                                  match_config)
        bm.run()
示例#5
0
    def run_agent(terminate_event, callback_event, reload_request,
                  bundle: BotConfigBundle, name, team, index, python_file,
                  agent_telemetry_queue, match_config: MatchConfig,
                  matchcomms_root: URL, spawn_id: str):

        # Set the working directory to one level above the bot cfg file.
        # This mimics the behavior you get when executing run.py in one of the
        # example bot repositories, so bots will be more likely to 'just work'
        # even if the developer is careless about file paths.
        os.chdir(Path(bundle.config_directory).parent)

        agent_class_wrapper = import_agent(python_file)
        config_file = agent_class_wrapper.get_loaded_class(
        ).base_create_agent_configurations()
        config_file.parse_file(bundle.config_obj,
                               config_directory=bundle.config_directory)

        if hasattr(agent_class_wrapper.get_loaded_class(),
                   "run_independently"):
            bm = BotManagerIndependent(terminate_event, callback_event,
                                       reload_request, config_file, name, team,
                                       index, agent_class_wrapper,
                                       agent_telemetry_queue, match_config,
                                       matchcomms_root, spawn_id)
        else:
            bm = BotManagerStruct(terminate_event, callback_event,
                                  reload_request, config_file, name, team,
                                  index, agent_class_wrapper,
                                  agent_telemetry_queue, match_config,
                                  matchcomms_root, spawn_id)
        bm.run()