コード例 #1
0
 def load_extension(self, extension_filename):
     try:
         extension_class = import_class_with_base(extension_filename, BaseExtension).get_loaded_class()
         self.extension = extension_class(self)
         self.game_interface.set_extension(self.extension)
     except FileNotFoundError as e:
         print(f'Failed to load extension: {e}')
コード例 #2
0
def make_match_config(challenge: dict, upgrades: dict,
                      player_configs: List[PlayerConfig],
                      script_configs: List[ScriptConfig]):
    """Setup the match, following the challenge rules and user's upgrades
    """
    match_config = MatchConfig()
    match_config.mutators = MutatorConfig()

    match_config.game_mode = game_mode_types[0]  # Soccar
    match_config.game_map = challenge.get("map")
    match_config.enable_state_setting = True

    for script_config in script_configs:
        script_config_bundle = get_script_config_bundle(
            script_config.config_path)
        script_class_wrapper = import_class_with_base(
            script_config_bundle.script_file, BaseStoryScript)
        script_class = script_class_wrapper.get_loaded_class()
        if "edit_match_config" in dir(script_class):
            enabled_upgrades = list(
                filter(lambda upgrade: upgrades[upgrade], upgrades.keys()))
            script_class.edit_match_config(match_config, challenge,
                                           enabled_upgrades)

    if DEBUG_MODE_SHORT_GAMES:
        match_config.mutators.max_score = "3 Goals"

    match_config.player_configs = player_configs
    match_config.script_configs = script_configs
    return match_config
コード例 #3
0
def get_exercises():
    files = glob.glob(exercise_folder + '*.py')
    classes = [
        import_class_with_base(file, TrainingExercise).loaded_class
        for file in files
    ]
    return [
        exercise_class(exercise_class.__name__) for exercise_class in classes
    ]
コード例 #4
0
def run_helper_process(python_file, metadata_queue, quit_event):
    """
    :param python_file: The absolute path of a python file containing the helper process that should be run.
    It must define a class which is a subclass of BotHelperProcess.
    :param metadata_queue: A queue from which the helper process will read AgentMetadata updates.
    :param quit_event: An event which should be set when rlbot is shutting down.
    """
    class_wrapper = import_class_with_base(python_file, BotHelperProcess)
    helper_class = class_wrapper.get_loaded_class()
    helper = helper_class(metadata_queue, quit_event)
    helper.start()
コード例 #5
0
ファイル: bot_config_bundle.py プロジェクト: dvptl68/RLBot
    def generate_loadout_config(self, player_index: int, team: int) -> LoadoutConfig:
        if self.loadout_generator_file:
            try:
                generator_wrapper = import_class_with_base(self.loadout_generator_file, BaseLoadoutGenerator)
                generator_class = generator_wrapper.get_loaded_class()
                generator = generator_class(Path(self.config_directory))
                loadout_config = generator.generate_loadout(player_index, team)
                if loadout_config and isinstance(loadout_config, LoadoutConfig):
                    return loadout_config
                else:
                    logger.warn(f"Generated loadout is invalid, will fall back to file. Loadout was: {loadout_config}")
            except Exception as e:
                logger.warn(f"Failed to generate loadout config, will fall back to file. Error was: {e}")

        config_object = self.get_looks_config()
        return load_bot_appearance(config_object, team)
コード例 #6
0
ファイル: setup_manager.py プロジェクト: NeedfulThings/RLBot
 def load_extension(self, extension_filename):
     extension_class = import_class_with_base(
         extension_filename, BaseExtension).get_loaded_class()
     self.extension = extension_class(self)
     self.game_interface.set_extension(self.extension)