Exemple #1
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)
Exemple #2
0
def read_match_config_from_file(match_config_path: Path) -> MatchConfig:
    """
    Parse the rlbot.cfg file on disk into the python datastructure.
    """
    config_obj = create_bot_config_layout()
    config_obj.parse_file(match_config_path, max_index=MAX_PLAYERS)
    return parse_match_config(config_obj, match_config_path, {}, {})
Exemple #3
0
    def setup_match(self):
        # Set up RLBot.cfg
        framework_config = create_bot_config_layout()
        config_location = os.path.join(os.path.dirname(__file__), 'rlbot.cfg')
        framework_config.parse_file(config_location, max_index=MAX_PLAYERS)
        match_config = parse_match_config(framework_config, config_location, {}, {})
        match_config.game_map = self.choreo_obj.map_name

        # The three blocks of code below are basically identical.
        # TODO Make them into a function?

        # Gets appearance list from choreo.
        appearances = self.choreo_obj.get_appearances(self.min_bots)
        # Checks that it is the correct length.
        if len(appearances) != self.min_bots:
            print('[RLBotChoreography]: Number of appearances does not match number of bots.')
            print('[RLBotChoreography]: Using default appearances.')
            appearances = ['default.cfg'] * self.min_bots

        # Gets teams list from choreo.
        teams = self.choreo_obj.get_teams(self.min_bots)
        # Checks that it is the correct length.
        if len(teams) != self.min_bots:
            print('[RLBotChoreography]: Number of teams does not match number of bots.')
            print('[RLBotChoreography]: Putting all on blue.')
            teams = [0] * self.min_bots

        # Gets names list from choreo.
        names = self.choreo_obj.get_names(self.min_bots)
        # Checks that it is the correct length.
        if len(names) != self.min_bots:
            print('[RLBotChoreography]: Number of names does not match number of bots.')
            print('[RLBotChoreography]: Using bot indices as names.')
            names = range(self.min_bots)

        # Loads appearances.
        looks_configs = {
            idx: create_looks_configurations().parse_file(
                os.path.abspath('./ChoreographyHive/appearances/' + file_name))
            for idx, file_name in enumerate(appearances)
        }

        # rlbot.cfg specifies only one bot, 
        # so we have to copy each and assign correct appearance.
        player_config = match_config.player_configs[0]
        match_config.player_configs.clear()
        for i in range(self.min_bots):
            copied = PlayerConfig()
            copied.name = names[i]
            copied.team = teams[i]
            copied.bot = player_config.bot
            copied.rlbot_controlled = player_config.rlbot_controlled
            copied.config_path = player_config.config_path
            copied.loadout_config = load_bot_appearance(looks_configs[i], copied.team)
            match_config.player_configs.append(copied)

        manager = SetupManager()
        manager.load_match_config(match_config, {})
        manager.connect_to_game()
        manager.start_match()
Exemple #4
0
 def load_overall_config(self, config_path=None):
     """
     Loads the overall config from the config path, or asks for a path if config_path is None
     :param config_path: the path to load the overall_config from, if None a path is requested
     :return:
     """
     if self.overall_config is None:
         self.overall_config = create_bot_config_layout()
     GUIAgent.overall_config = self.overall_config
     if config_path is None:
         config_path = QFileDialog.getOpenFileName(self, "Load Overall Config", "", "Config Files (*.cfg)")[0]
         if not config_path:
             self.statusbar.showMessage("No file selected, not loading config", 5000)
             return
     if config_path is None or not os.path.isfile(config_path):
         return
     if pathlib.Path(config_path).suffix != '.cfg':
         self.popup_message("This file is not a config file!", "Invalid File Extension", QMessageBox.Warning)
         return
     raw_parser = configparser.RawConfigParser()
     raw_parser.read(config_path, encoding='utf8')
     for section in self.overall_config.headers.keys():
         if not raw_parser.has_section(section):
             self.popup_message("Config file is missing the section {}, not loading it!".format(section), "Invalid Config File", QMessageBox.Warning)
             return
     self.overall_config_path = config_path
     self.overall_config.parse_file(raw_parser, 10)
     self.load_agents()
     self.update_teams_listwidgets()
     self.cfg_file_path_lineedit.setText(self.overall_config_path)
     self.update_team_settings()
     self.car_customisation.update_presets_widgets()
     self.agent_customisation.update_presets_widgets()
     self.mutator_customisation.update_comboboxes()
Exemple #5
0
def create_match_config(players):
    config_object = create_bot_config_layout()
    config_object.set_value(MATCH_CONFIGURATION_HEADER, PARTICIPANT_COUNT_KEY,
                            len(players))

    player_header = config_object.get_header(PARTICIPANT_CONFIGURATION_HEADER)
    for i in range(players):
        add_player_to_config(i, players[i], player_header)
    return config_object
Exemple #6
0
def record_atba():
    raw_config_parser = configparser.RawConfigParser()
    raw_config_parser.read(RLBOT_CONFIG_FILE)
    framework_config = create_bot_config_layout()
    framework_config.parse_file(raw_config_parser, max_index=10)

    manager = SetupManager()
    manager.startup()
    manager.load_config(framework_config=framework_config, config_location=RLBOT_CONFIG_FILE)
    manager.launch_bot_processes()
    manager.run()
Exemple #7
0
 def load_off_disk_overall_config(self):
     self.cfg_autosave_checkbutton.setChecked(False)
     self.cfg_autosave_checkbutton.setDisabled(True)
     if self.overall_config is None:
         self.overall_config = create_bot_config_layout()
     GUIAgent.overall_config = self.overall_config
     self.overall_config.init_indices(10)
     self.overall_config_path = ""
     self.load_agents()
     self.update_teams_listwidgets()
     self.cfg_file_path_lineedit.setText(self.overall_config_path)
     self.update_team_settings()
     self.car_customisation.update_presets_widgets()
     self.agent_customisation.update_presets_widgets()
Exemple #8
0
def record_atba():
    raw_config_parser = configparser.RawConfigParser()
    raw_config_parser.read(RLBOT_CONFIG_FILE)
    framework_config = create_bot_config_layout()
    framework_config.parse_file(raw_config_parser, max_index=10)

    manager = SetupManager()
    manager.connect_to_game()
    manager.load_config(framework_config=framework_config,
                        config_location=RLBOT_CONFIG_FILE)
    manager.launch_ball_prediction()
    manager.launch_quick_chat_manager()
    manager.launch_bot_processes()
    manager.start_match()
    manager.infinite_loop()  # Runs terminated by timeout in other thread.
Exemple #9
0
 def load_overall_config(self, config_path=None):
     """
     Loads the overall config from the config path, or asks for a path if config_path is None
     :param config_path: the path to load the overall_config from, if None a path is requested
     :return:
     """
     if self.overall_config is None:
         self.overall_config = create_bot_config_layout()
     GUIAgent.overall_config = self.overall_config
     if config_path is None:
         config_path = QFileDialog.getOpenFileName(
             self, "Load Overall Config", "", "Config Files (*.cfg)")[0]
         if not config_path:
             self.statusbar.showMessage(
                 "No file selected, not loading config", 5000)
             return
     if config_path is None or not os.path.isfile(config_path):
         return
     if pathlib.Path(config_path).suffix != '.cfg':
         self.popup_message("This file is not a config file!",
                            "Invalid File Extension", QMessageBox.Warning)
         return
     raw_parser = configparser.RawConfigParser()
     raw_parser.read(config_path, encoding='utf8')
     for section in ['Match Configuration', 'Participant Configuration']:
         if not raw_parser.has_section(section):
             self.popup_message(
                 f"Config file is missing the section {section}, not loading it!",
                 "Invalid Config File", QMessageBox.Warning)
             return
     self.overall_config_path = config_path
     self.overall_config.parse_file(raw_parser,
                                    MAX_PLAYERS,
                                    config_directory=os.path.dirname(
                                        self.overall_config_path))
     self.load_agents()
     # self.load_bot_directory(".")
     self.update_teams_listwidgets()
     self.cfg_file_path_lineedit.setText(self.overall_config_path)
     self.cfg_file_path_lineedit.setStyleSheet("")
     self.run_button.setEnabled(True)
     self.update_team_settings()
     self.car_customisation.update_presets_widgets()
     self.agent_customisation.update_presets_widgets()
     self.mutator_customisation.update_comboboxes()
Exemple #10
0
    def setup_match(self):
        # TODO This should be replaced?
        arguments = docopt(__doc__)

        bot_directory = arguments['--bot-folder']
        bundles = scan_directory_for_bot_configs(bot_directory)

        # Set up RLBot.cfg
        framework_config = create_bot_config_layout()
        config_location = os.path.join(os.path.dirname(__file__), 'rlbot.cfg')
        framework_config.parse_file(config_location, max_index=MAX_PLAYERS)
        match_config = parse_match_config(framework_config, config_location,
                                          {}, {})

        looks_configs = {
            idx: bundle.get_looks_config()
            for idx, bundle in enumerate(bundles)
        }
        names = [bundle.name for bundle in bundles]

        player_config = match_config.player_configs[0]
        match_config.player_configs.clear()
        for i in range(max(len(bundles), self.min_bots)):
            copied = PlayerConfig()
            copied.bot = player_config.bot
            copied.name = player_config.name
            copied.rlbot_controlled = player_config.rlbot_controlled
            copied.config_path = player_config.config_path
            copied.team = player_config.team if i % 2 == 0 else not player_config.team
            if i < len(bundles):
                copied.name = names[i]
                # If you want to override bot appearances to get a certain visual effect, e.g. with
                # specific boost colors, this is a good place to do it.
                copied.loadout_config = load_bot_appearance(
                    looks_configs[i], 0)
            match_config.player_configs.append(copied)

        manager = SetupManager()
        manager.load_match_config(match_config, {})
        manager.connect_to_game(
            RocketLeagueLauncherPreference(
                RocketLeagueLauncherPreference.STEAM, False))
        manager.start_match()
Exemple #11
0
 def load_off_disk_overall_config(self):
     self.cfg_autosave_checkbutton.setChecked(False)
     self.cfg_autosave_checkbutton.setDisabled(True)
     if self.overall_config is None:
         self.overall_config = create_bot_config_layout()
     GUIAgent.overall_config = self.overall_config
     self.overall_config.init_indices(10)
     self.overall_config_path = ""
     self.load_agents()
     self.update_teams_listwidgets()
     if not self.overall_config_path:
         self.cfg_file_path_lineedit.setStyleSheet("border: 1px solid red;")
         self.cfg_file_path_lineedit.setText("Please load a configuration file")
         self.blue_plus_toolbutton.setEnabled(False)
         self.orange_plus_toolbutton.setEnabled(False)
         self.run_button.setEnabled(False)
     else:
         self.cfg_file_path_lineedit.setText(self.overall_config_path)
     self.update_team_settings()
     self.car_customisation.update_presets_widgets()
     self.agent_customisation.update_presets_widgets()
     self.mutator_customisation.update_comboboxes()
Exemple #12
0
    def load_config(self,
                    framework_config=None,
                    config_location=DEFAULT_RLBOT_CONFIG_LOCATION,
                    bot_configs=None,
                    looks_configs=None):
        """
        :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=10)
        if bot_configs is None:
            bot_configs = {}
        if looks_configs is None:
            looks_configs = {}

        # Open anonymous shared memory for entire GameInputPacket and map buffer
        self.start_match_configuration = MatchSettings()

        self.num_participants, self.names, self.teams, self.python_files, self.parameters = parse_configurations(
            self.start_match_configuration, framework_config, config_location,
            bot_configs, looks_configs)

        self.game_interface.participants = self.num_participants
        self.game_interface.start_match_configuration = self.start_match_configuration

        extension_path = framework_config.get(RLBOT_CONFIGURATION_HEADER,
                                              EXTENSION_PATH_KEY)
        if extension_path is not None and extension_path != "None":
            self.load_extension(extension_path)