示例#1
0
def parse_match_settings(match_settings, config: ConfigObject):
    """
    Parses the matching settings modifying the match settings object.
    :param match_settings:
    :param config:
    :return:
    """

    match_settings.game_mode = config.get(MATCH_CONFIGURATION_HEADER,
                                          GAME_MODE)
    match_settings.game_map = config.get(MATCH_CONFIGURATION_HEADER, GAME_MAP)
    match_settings.skip_replays = config.getboolean(MATCH_CONFIGURATION_HEADER,
                                                    SKIP_REPLAYS)
    match_settings.instant_start = config.getboolean(
        MATCH_CONFIGURATION_HEADER, INSTANT_START)
    match_settings.existing_match_behavior = config.get(
        MATCH_CONFIGURATION_HEADER, EXISTING_MATCH_BEHAVIOR)
    match_settings.enable_lockstep = config.getboolean(
        MATCH_CONFIGURATION_HEADER, ENABLE_LOCKSTEP)
    match_settings.enable_rendering = config.getboolean(
        MATCH_CONFIGURATION_HEADER, ENABLE_RENDERING)
    match_settings.enable_state_setting = config.getboolean(
        MATCH_CONFIGURATION_HEADER, ENABLE_STATE_SETTING)
    match_settings.auto_save_replay = config.getboolean(
        MATCH_CONFIGURATION_HEADER, AUTO_SAVE_REPLAY)

    parse_mutator_settings(match_settings.mutators, config)
示例#2
0
def parse_match_config(config_parser: ConfigObject, config_location,
                       config_bundle_overrides,
                       looks_config_overrides) -> MatchConfig:

    match_config = MatchConfig()
    match_config.mutators = MutatorConfig()

    # Determine number of participants
    num_players = get_num_players(config_parser)

    parse_match_settings(match_config, config_parser)

    # Retrieve bot config files
    config_bundles = get_bot_config_bundles(num_players, config_parser,
                                            config_location,
                                            config_bundle_overrides)

    match_config.player_configs = []

    human_index_tracker = IncrementingInteger(0)

    # Set configuration values for bots and store name and team
    for i in range(num_players):

        config_bundle = config_bundles[i]

        looks_config_object = None
        if i in looks_config_overrides:
            looks_config_object = looks_config_overrides[i]

        player_config = _load_bot_config(i, config_bundle, looks_config_object,
                                         config_parser, human_index_tracker)

        match_config.player_configs.append(player_config)

    extension_path = config_parser.get(RLBOT_CONFIGURATION_HEADER,
                                       EXTENSION_PATH_KEY)
    if extension_path and extension_path != 'None':  # The string 'None' ends up in people's config a lot.
        match_config.extension_config = ExtensionConfig()
        match_config.extension_config.python_file_path = extension_path

    match_config.networking_role = config_parser.get(
        RLBOT_CONFIGURATION_HEADER, NETWORKING_ROLE_KEY)
    match_config.network_address = config_parser.get(
        RLBOT_CONFIGURATION_HEADER, NETWORK_ADDRESS_KEY)

    match_config.script_configs = [
        ScriptConfig(bundle.config_path)
        for bundle in get_script_config_bundles(config_parser, config_location)
    ]

    return match_config
示例#3
0
def parse_match_config(config_parser: ConfigObject, config_location,
                       config_bundle_overrides,
                       looks_config_overrides) -> MatchConfig:

    match_config = MatchConfig()
    match_config.mutators = MutatorConfig()

    # Determine number of participants
    num_players = get_num_players(config_parser)

    parse_match_settings(match_config, config_parser)

    # Retrieve bot config files
    config_bundles = get_bot_config_bundles(num_players, config_parser,
                                            config_location,
                                            config_bundle_overrides)

    match_config.player_configs = []

    human_index_tracker = IncrementingInteger(0)

    # Set configuration values for bots and store name and team
    for i in range(num_players):

        config_bundle = config_bundles[i]

        if i not in looks_config_overrides:
            looks_config_object = config_bundle.get_looks_config()
        else:
            looks_config_object = looks_config_overrides[i]

        player_config = _load_bot_config(i, config_bundle, looks_config_object,
                                         config_parser, human_index_tracker)

        match_config.player_configs.append(player_config)

    for path in config_parser.get(BOTLESS_AGENT_CONFIGURATION_HEADER,
                                  BOTLESS_AGENT_PATH_KEY):
        if path != 'None':
            match_config.botless_agents.append(path)

    extension_path = config_parser.get(RLBOT_CONFIGURATION_HEADER,
                                       EXTENSION_PATH_KEY)
    if extension_path and extension_path != 'None':  # The string 'None' ends up in people's config a lot.
        match_config.extension_config = ExtensionConfig()
        match_config.extension_config.python_file_path = extension_path

    return match_config
示例#4
0
    def load_config(self,
                    framework_config: ConfigObject = None,
                    config_location=DEFAULT_RLBOT_CONFIG_LOCATION,
                    bot_configs=None,
                    looks_configs=None):
        """
        Loads the configuration into internal data structures, which prepares us to later
        launch bot processes and start the match.

        :param framework_config: A config object that indicates what bots to run. May come from parsing a rlbot.cfg.
        :param config_location: The location of the rlbot.cfg file, which will be used to resolve relative paths.
        :param bot_configs: Overrides for bot configurations.
        :param looks_configs: Overrides for looks configurations.
        """
        self.logger.debug('reading the configs')

        # Set up RLBot.cfg
        if framework_config is None:
            framework_config = create_bot_config_layout()
            framework_config.parse_file(config_location, max_index=MAX_PLAYERS)
        if bot_configs is None:
            bot_configs = {}
        if looks_configs is None:
            looks_configs = {}

        match_config = parse_match_config(framework_config, config_location,
                                          bot_configs, looks_configs)
        self.load_match_config(match_config, bot_configs)
        raw_launcher_string = framework_config.get(RLBOT_CONFIGURATION_HEADER,
                                                   LAUNCHER_PREFERENCE_KEY)
        if raw_launcher_string == RocketLeagueLauncherPreference.STEAM:
            self.launcher_preference = RocketLeagueLauncherPreference(
                RocketLeagueLauncherPreference.STEAM, False)
        else:
            self.launcher_preference = DEFAULT_LAUNCHER_PREFERENCE
def parse_match_settings(match_settings, config: ConfigObject):
    """
    Parses the matching settings modifying the match settings object.
    :param match_settings:
    :param config:
    :return:
    """

    match_settings.game_mode = config.get(MATCH_CONFIGURATION_HEADER,
                                          GAME_MODE)
    match_settings.game_map = config.get(MATCH_CONFIGURATION_HEADER, GAME_MAP)
    match_settings.skip_replays = config.getboolean(MATCH_CONFIGURATION_HEADER,
                                                    SKIP_REPLAYS)
    match_settings.instant_start = config.getboolean(
        MATCH_CONFIGURATION_HEADER, INSTANT_START)

    parse_mutator_settings(match_settings.mutators, config)
示例#6
0
 def __init__(self, config_directory, config_obj: ConfigObject, config_file_name: str = None):
     self.config_directory = config_directory
     self.config_file_name = config_file_name
     self.config_path = os.path.join(self.config_directory, self.config_file_name)
     self.config_obj = config_obj
     self.base_agent_config = RLBotRunnable.base_create_agent_configurations()
     self.base_agent_config.parse_file(self.config_obj, config_directory=config_directory)
     self.name = config_obj.get(BOT_CONFIG_MODULE_HEADER, BOT_NAME_KEY)
     self.supports_early_start = self.base_agent_config.get(BOT_CONFIG_MODULE_HEADER, SUPPORTS_EARLY_START_KEY)
     self.requirements_file = self.get_absolute_path(BOT_CONFIG_MODULE_HEADER, REQUIREMENTS_FILE_KEY)
示例#7
0
def get_script_config_bundles(match_config: ConfigObject, config_location):
    """
    Adds all the script config bundles found in the match config file.
    Attempts to read indexed config keys until it hits an empty one.
    """
    config_bundles = []
    for i in itertools.count():
        script_config_relative_path = match_config.get(SCRIPT_CONFIGURATION_HEADER, SCRIPT_CONFIG_KEY, i)
        if script_config_relative_path is None or script_config_relative_path == 'None':
            break
        script_config_path = os.path.join(os.path.dirname(config_location), script_config_relative_path)
        config_bundles.append(get_script_config_bundle(script_config_path))

    return config_bundles
示例#8
0
 def __init__(self,
              config_directory,
              config_obj: ConfigObject,
              config_file_name: str = None):
     self.config_directory = config_directory
     self.config_file_name = config_file_name
     self.config_path = os.path.join(self.config_directory,
                                     self.config_file_name)
     self.config_obj = config_obj
     self.base_agent_config = BaseAgent.base_create_agent_configurations()
     self.base_agent_config.parse_file(self.config_obj,
                                       config_directory=config_directory)
     self.name = config_obj.get(BOT_CONFIG_MODULE_HEADER, BOT_NAME_KEY)
     self.looks_path = self.get_absolute_path(BOT_CONFIG_MODULE_HEADER,
                                              LOOKS_CONFIG_KEY)
     self.python_file = self.get_absolute_path(BOT_CONFIG_MODULE_HEADER,
                                               PYTHON_FILE_KEY)
示例#9
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
示例#10
0
 def __init__(self,
              config_directory,
              config_obj: ConfigObject,
              config_file_name: str = None):
     self.config_directory = config_directory
     self.config_file_name = config_file_name
     self.config_path = os.path.join(self.config_directory,
                                     self.config_file_name)
     self.config_obj = config_obj
     self.base_agent_config = BaseAgent.base_create_agent_configurations()
     self.base_agent_config.parse_file(self.config_obj,
                                       config_directory=config_directory)
     self.name = config_obj.get(BOT_CONFIG_MODULE_HEADER, BOT_NAME_KEY)
     self.looks_path = self.get_absolute_path(BOT_CONFIG_MODULE_HEADER,
                                              LOOKS_CONFIG_KEY)
     self.python_file = self.get_absolute_path(BOT_CONFIG_MODULE_HEADER,
                                               PYTHON_FILE_KEY)
     self.loadout_generator_file = self.get_absolute_path(
         BOT_CONFIG_MODULE_HEADER, LOADOUT_GENERATOR_FILE_KEY)
     self.supports_early_start = self.base_agent_config.get(
         BOT_CONFIG_MODULE_HEADER, SUPPORTS_EARLY_START_KEY)
示例#11
0
def get_bot_config_bundles(num_participants, config: ConfigObject, config_location, config_bundle_overrides):
    """
    Adds all the config files or config objects.
    :param num_participants:
    :param config:
    :param config_location: The location of the rlbot.cfg file
    :param config_bundle_overrides: These are configs that have been loaded from the gui, they get assigned a bot index.
    :return:
    """
    config_bundles = []
    for i in range(num_participants):
        if i in config_bundle_overrides:
            config_bundles.append(config_bundle_overrides[i])
            logger.debug("Config available")
        else:
            bot_config_relative_path = config.get(PARTICIPANT_CONFIGURATION_HEADER, PARTICIPANT_CONFIG_KEY, i)
            bot_config_path = os.path.join(os.path.dirname(config_location), bot_config_relative_path)
            config_bundles.append(get_bot_config_bundle(bot_config_path))
            logger.debug("Reading raw config")

    return config_bundles