Ejemplo n.º 1
0
def versus_line_goalie_match_config(attacker: Path, goalie: Path = BotConfigs.line_goalie) -> MatchConfig:
    match_config = make_empty_match_config()
    match_config.player_configs = [
        PlayerConfig.bot_config(attacker, Team.ORANGE),
        PlayerConfig.bot_config(goalie, Team.BLUE),
    ]
    return match_config
Ejemplo n.º 2
0
def make_default_playlist() -> Playlist:

    # Choose which spawns you want to test.
    exercises = [
        #KickoffExercise('Both Corners', blue_spawns=[Spawns.CORNER_R, Spawns.CORNER_L], orange_spawns = []),
        #KickoffExercise('Right Corner 50/50', blue_spawns=[Spawns.CORNER_R], orange_spawns = [Spawns.CORNER_R]),
        KickoffExercise('Right Corner',
                        blue_spawns=[Spawns.CORNER_R],
                        orange_spawns=[]),
        KickoffExercise('Left Corner',
                        blue_spawns=[Spawns.CORNER_L],
                        orange_spawns=[]),
        KickoffExercise('Back Right',
                        blue_spawns=[Spawns.BACK_R],
                        orange_spawns=[]),
        KickoffExercise('Back Left',
                        blue_spawns=[Spawns.BACK_L],
                        orange_spawns=[]),
        KickoffExercise('Straight',
                        blue_spawns=[Spawns.STRAIGHT],
                        orange_spawns=[]),
    ]

    for ex in exercises:
        # The number of players in the match_config needs to match the number of spawns.

        # Replace with path to your bot.
        ex.match_config.player_configs = \
        [PlayerConfig.bot_config(BotConfigs.simple_bot, Team.BLUE) for _ in ex.blue_spawns] + \
        [PlayerConfig.bot_config(BotConfigs.simple_bot, Team.ORANGE) for _ in ex.orange_spawns]

    return exercises
Ejemplo n.º 3
0
def make_default_playlist() -> Playlist:
    # Choose which spawns you want to test.
    exercises = [
        KickoffExercise('Right Corner',
                        blue_spawns=[Spawns.CORNER_R],
                        orange_spawns=[Spawns.CORNER_R]),
        KickoffExercise('Left Corner',
                        blue_spawns=[Spawns.CORNER_L],
                        orange_spawns=[Spawns.CORNER_L]),
        KickoffExercise('Back Right',
                        blue_spawns=[Spawns.BACK_R],
                        orange_spawns=[Spawns.BACK_R]),
        KickoffExercise('Back Left',
                        blue_spawns=[Spawns.BACK_L],
                        orange_spawns=[Spawns.BACK_L]),
        KickoffExercise('Straight',
                        blue_spawns=[Spawns.STRAIGHT],
                        orange_spawns=[Spawns.STRAIGHT]),
    ]

    for ex in exercises:
        # The length of players in the match_config needs to match the number or spawns.

        # Replace with path to your bot or bots.
        ex.match_config.player_configs = \
            [PlayerConfig.bot_config(Path(Path(__file__).absolute().parent.parent.parent / 'Derevo.cfg'), Team.BLUE) for
             _ in ex.blue_spawns] + \
            [PlayerConfig.bot_config(Path(Path(__file__).absolute().parent.parent.parent / 'Derevo.cfg'), Team.ORANGE)
             for _ in ex.orange_spawns]

    return exercises
Ejemplo n.º 4
0
def set_random_psyonix_bot_preset(player: PlayerConfig):
    """
    Sets the name and loadout to a randomly selected psyonix bot preset.
    """
    loadout_file = PSYONIX_PRESET_LIST[0]
    PSYONIX_PRESET_LIST.append(PSYONIX_PRESET_LIST.pop(0))  # Move preset to the end of the list.
    loadout_config = create_looks_configurations().parse_file(loadout_file)
    player.loadout_config = load_bot_appearance(loadout_config, player.team)
    player.name = loadout_file.name.split("_")[1].title()
    player.name = ["Rookie ", "Pro ", ""][min(int(abs(player.bot_skill) * 3), 2)] + player.name
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
def make_default_playlist():
    # Add the exercises
    exercises = get_exercises()

    # Configure Wildfire and friends (or foes!)
    for exercise in exercises:
        exercise.match_config.player_configs = [
            PlayerConfig.bot_config(Path(wildfire_test_path), Team.BLUE),
            PlayerConfig.bot_config(Path(opponent_path), Team.ORANGE)
        ]

    return exercises
Ejemplo n.º 8
0
def make_kickoff_config(
        other_bot: PlayerConfig,
        bot_thats_supposed_to_win: PlayerConfig = None) -> MatchConfig:
    if bot_thats_supposed_to_win is None:
        bot_thats_supposed_to_win = make_defendinator_player_config(Team.BLUE)
    bot_thats_supposed_to_win.team = Team.BLUE.value
    other_bot.team = Team.ORANGE.value

    match_config = make_empty_match_config()
    match_config.player_configs = [
        bot_thats_supposed_to_win,
        other_bot,
    ]
    return match_config
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
def make_default_playlist():
    exercises = [
        KickoffExercise('Straight',
                        blue_spawns=[Spawns.STRAIGHT],
                        orange_spawns=[]),
        KickoffExercise('Right Corner',
                        blue_spawns=[Spawns.CORNER_R],
                        orange_spawns=[]),
        KickoffExercise('Left Corner',
                        blue_spawns=[Spawns.CORNER_L],
                        orange_spawns=[]),
        KickoffExercise('Back Right',
                        blue_spawns=[Spawns.BACK_R],
                        orange_spawns=[]),
        KickoffExercise('Back Left',
                        blue_spawns=[Spawns.BACK_L],
                        orange_spawns=[])
    ]

    for exercise in exercises:
        exercise.match_config.player_configs = [
            PlayerConfig.bot_config(
                Path(__file__).absolute().parent.parent / 'src' / 'bot.cfg',
                Team.BLUE)
        ]

    return exercises
Ejemplo n.º 12
0
 def bot_to_config(self, bot: BotID, bots: Mapping[BotID, BotConfigBundle],
                   team: Team) -> PlayerConfig:
     config = PlayerConfig.bot_config(Path(bots[bot].config_path), team)
     # Resolve Psyonix bots -- only Psyonix bots are in this list
     if bot in psyonix_bot_skill:
         config.rlbot_controlled = False
         config.bot_skill = psyonix_bot_skill[bot]
     return config
Ejemplo n.º 13
0
def make_match_config_with_bots(blue_bots: List[Path] = None,
                                orange_bots: List[Path] = None) -> MatchConfig:
    """
    Returns a match config containing the provided bots playing soccar.
    The bot index order will be blue_bots then orange_bots.
    Has some mutators which are usually useful for bot training.
    """
    if blue_bots is None: blue_bots = []
    if orange_bots is None: orange_bots = []
    blue_players = [
        PlayerConfig.bot_config(bot_path, Team.BLUE) for bot_path in blue_bots
    ]
    orange_players = [
        PlayerConfig.bot_config(bot_path, Team.ORANGE)
        for bot_path in orange_bots
    ]
    return make_match_config_with_players(blue_players + orange_players)
Ejemplo n.º 14
0
def make_bot_config(config_bundle: BotConfigBundle,
                    team: Team) -> PlayerConfig:
    # Our main concern here is Psyonix bots
    player_config = PlayerConfig.bot_config(Path(config_bundle.config_path),
                                            team)
    player_config.rlbot_controlled = player_config.name not in psyonix_bots.keys(
    )
    player_config.bot_skill = psyonix_bots.get(player_config.name, 1.0)
    return player_config
Ejemplo n.º 15
0
def make_default_playlist() -> Playlist:
    exercises = [DribbleDrop('Dribble Drop'), DribbleRoll('Dribble Roll')]

    for ex in exercises:
        ex.match_config.player_configs = [
            PlayerConfig.bot_config(Path(__file__).absolute().parent.parent.parent / 'Derevo.cfg', Team.BLUE)
        ]

    return exercises
Ejemplo n.º 16
0
def make_default_playlist():
    exercises = [BallRollingToGoalie("first training exercise")]
    for e in exercises:
        e.match_config.player_configs = [
            PlayerConfig.bot_config(
                Path(__file__).absolute().parent.parent / 'babySteps.cfg',
                Team.BLUE)
        ]
    return exercises
Ejemplo n.º 17
0
def make_match_config_with_my_bot() -> MatchConfig:
    # Makes a config which only has our bot in it for now.
    # For more defails: https://youtu.be/uGFmOZCpel8?t=375
    match_config = make_empty_match_config()
    match_config.player_configs = [
        PlayerConfig.bot_config(
            Path(__file__).absolute().parent.parent / 'bean.cfg', Team.BLUE),
    ]
    return match_config
Ejemplo n.º 18
0
def make_playlist(bot_info, team):
    playlist = []
    for bot_name, path in bot_info:
        ex: SimpleExercise = SimpleExercise(bot_name, team=team)
        t = Team.BLUE if team == 1 else Team.ORANGE
        ex.match_config.player_configs = [
            PlayerConfig.bot_config(Path(path), t)
        ]
        playlist.append(ex)
    return playlist
Ejemplo n.º 19
0
def make_default_playlist() -> Playlist:
    team = Team.BLUE
    ex: SimpleExercise = SimpleExercise("Simple",
                                        team=1 if team == Team.BLUE else -1)
    ex.match_config.player_configs = [
        PlayerConfig.bot_config(
            Path(__file__).absolute().parent / "simple_bot" / 'SimpleBot.cfg',
            team)
    ]
    return [ex]
Ejemplo n.º 20
0
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
Ejemplo n.º 21
0
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
Ejemplo n.º 22
0
def make_default_playlist():
    exercises = [get_shot()]

    for exercise in exercises:
        exercise.match_config.player_configs = [
            PlayerConfig.bot_config(
                Path(__file__).absolute().parent.parent / 'YangBot' / 'src' /
                'main' / 'python' / 'yangbot.cfg', Team.BLUE)
        ]

    return exercises
Ejemplo n.º 23
0
def make_match_config(working_dir: WorkingDir,
                      bot_id_pair: Tuple[BotID, BotID]) -> MatchConfig:
    match_config = read_match_config_from_file(
        PackageFiles.default_match_config)
    match_config.game_map = random.choice([
        'ChampionsField',
        'Farmstead',
        'StarbaseArc',
        'DFHStadium',
        'SaltyShores',
        'Wasteland',
    ])
    if random.random() < .5:
        bot_id_pair = bot_id_pair[::-1]  # mix up the colors a bit.
    match_config.player_configs = [
        PlayerConfig.bot_config(working_dir.bots / bot_id_pair[0], Team.BLUE),
        PlayerConfig.bot_config(working_dir.bots / bot_id_pair[1],
                                Team.ORANGE),
    ]
    return match_config
Ejemplo n.º 24
0
def make_default_playlist():
    exercises = [HookShot('Trash Training')]

    for exercise in exercises:
        exercise.match_config.player_configs = [
            PlayerConfig.bot_config(
                Path(__file__).absolute().parent.parent / 'Trashbag' / 'Trashbag.cfg', 
                Team.BLUE
            )
        ]
    return exercises
Ejemplo n.º 25
0
def make_default_playlist():
    exercises = [
        BallRollingTowardsWall('Test Training!'),
    ]
    for exercise in exercises:
        exercise.match_config.player_configs = [
            PlayerConfig.bot_config(
                Path(__file__).absolute().parent / 'BroccoliBot.cfg',
                Team.BLUE)
        ]

    return exercises
Ejemplo n.º 26
0
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
Ejemplo n.º 27
0
def make_default_playlist():
    exercises = import_exercises(_example_rl_custom_training_json)
    exercises.pop(14)  # 14 doesnt end properly
    exercises.pop(23)  # 24 doesnt end properly
    exercises.pop(24)  # 26 doesnt end properly
    for exercise in exercises:
        exercise.match_config.player_configs = [
            PlayerConfig.bot_config(
                Path(__file__).absolute().parent / 'Trashbag' / 'Trashbag.cfg',
                Team.BLUE)
        ]
    return exercises
def make_match_config_with_my_bot(name) -> MatchConfig:
    # Makes a config which only has our bot in it for now.
    # For more defails: https://youtu.be/uGFmOZCpel8?t=375
    match_config = make_empty_match_config()
    match_config.player_configs = [
        PlayerConfig.bot_config(
            Path(__file__).absolute().parent.parent / 'rashBot' / 'rashBot.cfg', #            Path(__file__).absolute().parent.parent / 'stick' / 'stick.cfg',
            Team.BLUE
        )
    ]
    match_config.player_configs[0].name = name
    return match_config
Ejemplo n.º 29
0
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
Ejemplo n.º 30
0
 def test_dribbling(self):
     exercise = Dribbling('Dribbling')
     exercise.match_config.player_configs = [
         PlayerConfig.bot_config(
             Path(__file__).absolute().parent.parent.parent / 'Derevo.cfg',
             Team.BLUE)
     ]
     result_iter = run_playlist([exercise])
     results = list(result_iter)
     result = results[0]
     self.assertEqual(len(results), 1)
     self.assertEqual(result.exercise.name, 'Dribbling')
     self.assertIsInstance(result.grade, Pass)