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()
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)
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()