Esempio n. 1
0
def load_bot_config(index, bot_configuration, config_bundle: BotConfigBundle,
                    looks_config_object, overall_config, name_dict,
                    human_index_tracker: IncrementingInteger):
    """
    Loads the config data of a single bot
    :param index: This is the bot index (where it appears in game_cars)
    :param bot_configuration: This is the game_tick_packet configuration that is sent back to the game
    :param config_bundle: A config object for a single bot
    :param overall_config: This is the config for the entire session not one particular bot
    :param name_dict: A mapping of used names so we can make sure to not reuse bot names.
    :param human_index_tracker: An object of type HumanIndexManager that helps set human_index correctly.
    :return:
    """
    team_num = get_team(overall_config, index)

    bot_configuration.team = team_num

    # Setting up data about what type of bot it is
    bot_type = overall_config.get(PARTICIPANT_CONFIGURATION_HEADER,
                                  PARTICIPANT_TYPE_KEY, index)
    bot_configuration.bot, bot_configuration.rlbot_controlled = get_bot_options(
        bot_type)
    bot_configuration.bot_skill = overall_config.getfloat(
        PARTICIPANT_CONFIGURATION_HEADER, PARTICIPANT_BOT_SKILL_KEY, index)

    if not bot_configuration.bot:
        bot_configuration.human_index = human_index_tracker.increment()

    loadout_header = BOT_CONFIG_LOADOUT_HEADER
    if team_num == 1 and looks_config_object.has_section(
            BOT_CONFIG_LOADOUT_ORANGE_HEADER):
        loadout_header = BOT_CONFIG_LOADOUT_ORANGE_HEADER

    # Setting up the bots name
    bot_name = config_bundle.config_obj.get(BOT_CONFIG_MODULE_HEADER,
                                            BOT_NAME_KEY)
    bot_configuration.name = get_sanitized_bot_name(name_dict, bot_name)

    BaseAgent._parse_bot_loadout(bot_configuration, looks_config_object,
                                 loadout_header)

    python_file = 'NO_MODULE_FOR_PARTICIPANT'
    bot_parameters = None

    if bot_configuration.rlbot_controlled:
        # Python file relative to the config location.
        python_file = config_bundle.get_absolute_path(BOT_CONFIG_MODULE_HEADER,
                                                      PYTHON_FILE_KEY)
        agent_class_wrapper = import_agent(python_file)
        bot_parameters = agent_class_wrapper.get_loaded_class(
        ).base_create_agent_configurations()
        bot_parameters.parse_file(
            config_bundle.config_obj,
            config_directory=config_bundle.config_directory)

    return bot_name, team_num, python_file, bot_parameters
Esempio n. 2
0
def create_player_config(bot: dict, human_index_tracker: IncrementingInteger):
    player_config = PlayerConfig()
    player_config.bot = bot['type'] in ('rlbot', 'psyonix')
    player_config.rlbot_controlled = bot['type'] in ('rlbot', 'party_member_bot')
    player_config.bot_skill = bot['skill']
    player_config.human_index = 0 if player_config.bot else human_index_tracker.increment()
    player_config.name = bot['name']
    player_config.team = int(bot['team'])
    if 'path' in bot and bot['path']:
        player_config.config_path = bot['path']
    return player_config
Esempio n. 3
0
def _load_bot_config(index, config_bundle: BotConfigBundle,
                     looks_config_object: ConfigObject,
                     overall_config: ConfigObject,
                     human_index_tracker: IncrementingInteger) -> PlayerConfig:
    """
    Loads the config data of a single bot
    :param index: This is the bot index (where it appears in game_cars)
    :param bot_configuration: A config object that will eventually be transformed and sent to the game.
    :param config_bundle: A config object for a single bot
    :param overall_config: This is the config for the entire session not one particular bot
    :param human_index_tracker: An object of type HumanIndexManager that helps set human_index correctly.
    :return:
    """

    bot_configuration = PlayerConfig()
    bot_configuration.config_path = config_bundle.config_path

    team_num = get_team(overall_config, index)

    bot_configuration.team = team_num

    # Setting up data about what type of bot it is
    bot_type = overall_config.get(PARTICIPANT_CONFIGURATION_HEADER,
                                  PARTICIPANT_TYPE_KEY, index)
    bot_configuration.bot, bot_configuration.rlbot_controlled = get_bot_options(
        bot_type)
    bot_configuration.bot_skill = overall_config.getfloat(
        PARTICIPANT_CONFIGURATION_HEADER, PARTICIPANT_BOT_SKILL_KEY, index)

    if not bot_configuration.bot:
        bot_configuration.human_index = human_index_tracker.increment()

    # Setting up the bots name
    bot_configuration.name = config_bundle.name

    if looks_config_object:
        loadout_config = load_bot_appearance(looks_config_object, team_num)
    else:
        loadout_config = config_bundle.generate_loadout_config(index, team_num)

    bot_configuration.loadout_config = loadout_config

    return bot_configuration