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 make_allstar_player_config(team: Team) -> PlayerConfig: config = PlayerConfig() config.bot = True config.rlobt_controlled = False config.bot_skill = 1.0 config.name = 'Psyonix Bot' return config
def make_human_config(team: Team): player_config = PlayerConfig() player_config.bot = False player_config.rlbot_controlled = False player_config.human_index = 0 player_config.team = team.value player_config.name = "" return player_config
def pysonix_to_player_config(player: dict, team: Team): player_config = PlayerConfig() player_config.bot = True player_config.rlbot_controlled = False player_config.bot_skill = player["skill"] if "skill" in player else 1 player_config.name = player["name"] player_config.team = team.value # should be able to customize "loadout_config" return player_config
def create_player_config(self, config_path: str) -> PlayerConfig: player_config = PlayerConfig() player_config.bot = True player_config.rlbot_controlled = True player_config.bot_skill = 1 player_config.human_index = 0 player_config.name = self.name player_config.team = 0 player_config.config_path = config_path player_config.spawn_id = self.spawn_id return player_config
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
def create_player_config(name: str, team: int, spawn_id: int, config_path: str): player_config = PlayerConfig() player_config.bot = True player_config.rlbot_controlled = True player_config.bot_skill = 1 player_config.human_index = 0 player_config.name = name player_config.team = team player_config.spawn_id = spawn_id player_config.config_path = config_path return player_config
def rlbot_to_player_config(player: dict, team: Team): bot_path = collapse_path(player["path"]) player_config = PlayerConfig() player_config.bot = True player_config.rlbot_controlled = True player_config.name = player["name"] player_config.team = team.value player_config.config_path = bot_path config = get_bot_config_bundle(bot_path) loadout = load_bot_appearance(config.get_looks_config(), team.value) player_config.loadout_config = loadout return player_config
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
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()
def __init__(self): match_config = MatchConfig() match_config.game_mode = 'Soccer' match_config.game_map = 'Mannfield_Night' match_config.existing_match_behavior = 'Continue And Spawn' match_config.mutators = MutatorConfig() match_config.mutators.match_length = 'Unlimited' # there needs to be at least one bot for the match to start bot_config = PlayerConfig() bot_config.name = "Dummy" bot_config.team = 0 bot_config.bot = True bot_config.rlbot_controlled = True match_config.player_configs = [bot_config] sm = SetupManager() sm.connect_to_game() sm.load_match_config(match_config) sm.start_match() self.game_interface: GameInterface = sm.game_interface
def rlbot_to_player_config(player: dict, team: Team): bot_path = player["path"] if isinstance(bot_path, list): bot_path = path.join(*bot_path) if "$RLBOTPACKROOT" in bot_path: for bot_folder in rlbot_gui.bot_folder_settings["folders"].keys(): adjusted_folder = path.join(bot_folder, "RLBotPack-master") subbed_path = bot_path.replace("$RLBOTPACKROOT", adjusted_folder) if path.exists(subbed_path): print("it exists!") bot_path = subbed_path break player_config = PlayerConfig() player_config.bot = True player_config.rlbot_controlled = True player_config.name = player["name"] player_config.team = team.value player_config.config_path = bot_path return player_config
def spawn_car_in_showroom(loadout_config: LoadoutConfig, team: int, showcase_type: str, map_name: str, launcher_prefs: RocketLeagueLauncherPreference): match_config = MatchConfig() match_config.game_mode = 'Soccer' match_config.game_map = map_name match_config.instant_start = True match_config.existing_match_behavior = 'Continue And Spawn' match_config.networking_role = NetworkingRole.none match_config.enable_state_setting = True match_config.skip_replays = True bot_config = PlayerConfig() bot_config.bot = True bot_config.rlbot_controlled = True bot_config.team = team bot_config.name = "Showroom" bot_config.loadout_config = loadout_config match_config.player_configs = [bot_config] match_config.mutators = MutatorConfig() match_config.mutators.boost_amount = 'Unlimited' match_config.mutators.match_length = 'Unlimited' global sm if sm is None: sm = SetupManager() sm.connect_to_game(launcher_preference=launcher_prefs) sm.load_match_config(match_config) sm.start_match() game_state = GameState( cars={0: CarState(physics=Physics( location=Vector3(0, 0, 20), velocity=Vector3(0, 0, 0), angular_velocity=Vector3(0, 0, 0), rotation=Rotator(0, 0, 0) ))}, ball=BallState(physics=Physics( location=Vector3(0, 0, -100), velocity=Vector3(0, 0, 0), angular_velocity=Vector3(0, 0, 0) )) ) player_input = PlayerInput() team_sign = -1 if team == 0 else 1 if showcase_type == "boost": player_input.boost = True player_input.steer = 1 game_state.cars[0].physics.location.y = -1140 game_state.cars[0].physics.velocity.x = 2300 game_state.cars[0].physics.angular_velocity.z = 3.5 elif showcase_type == "throttle": player_input.throttle = 1 player_input.steer = 0.56 game_state.cars[0].physics.location.y = -1140 game_state.cars[0].physics.velocity.x = 1410 game_state.cars[0].physics.angular_velocity.z = 1.5 elif showcase_type == "back-center-kickoff": game_state.cars[0].physics.location.y = 4608 * team_sign game_state.cars[0].physics.rotation.yaw = -0.5 * pi * team_sign elif showcase_type == "goal-explosion": game_state.cars[0].physics.location.y = -2000 * team_sign game_state.cars[0].physics.rotation.yaw = -0.5 * pi * team_sign game_state.cars[0].physics.velocity.y = -2300 * team_sign game_state.ball.physics.location = Vector3(0, -3500 * team_sign, 93) sm.game_interface.update_player_input(player_input, 0) sm.game_interface.set_game_state(game_state)