def run_game(nbr_of_games, enable_forward_model): config = ffai.load_config("gym-11") config.fast_mode = True ruleset = ffai.load_rule_set(config.ruleset) home = ffai.load_team_by_filename("human", ruleset) away = ffai.load_team_by_filename("human", ruleset) away_agent = Agent("Human 1", human=True, agent_id=1) home_agent = Agent("Human 2", human=True, agent_id=2) seed = 0 random_agent = ffai.make_bot('random') random_agent.rnd = np.random.RandomState(seed) for _ in range(nbr_of_games): game = Game(seed, home, away, home_agent, away_agent, config) game.init() if enable_forward_model: game.enable_forward_model() while not game.state.game_over: game.step(random_agent.act(game))
print("I ({}) won".format(self.name)) print(self.my_team.state.score, "-", self.opp_team.state.score) else: print("I ({}) lost".format(self.name)) print(self.my_team.state.score, "-", self.opp_team.state.score) # Register MyScriptedBot ffai.register_bot('scripted', MyScriptedBot) if __name__ == "__main__": # Uncomment to this to evaluate the bot against the random baseline # Load configurations, rules, arena and teams config = ffai.load_config("bot-bowl-iii") config.competition_mode = False config.pathfinding_enabled = True # config = get_config("gym-7.json") # config = get_config("gym-5.json") # config = get_config("gym-3.json") ruleset = ffai.load_rule_set(config.ruleset, all_rules=False) # We don't need all the rules arena = ffai.load_arena(config.arena) home = ffai.load_team_by_filename("human", ruleset) away = ffai.load_team_by_filename("human", ruleset) # Play 10 games for i in range(10): home_agent = ffai.make_bot('scripted') home_agent.name = "Scripted Bot" away_agent = ffai.make_bot('random')
#!/usr/bin/env python3 import ffai import ffai.ai.bots.testbots # Load competition configuration for the bot bowl config = ffai.load_config('bot-bowl-ii') # Get ruleset ruleset = ffai.load_rule_set(config.ruleset, all_rules=False) # Load team to be used human_team_a = ffai.load_team_by_filename('human', ruleset) human_team_b = ffai.load_team_by_filename('human', ruleset) # Random vs. Random competition = ffai.Competition('MyCompetition', competitor_a_team=human_team_a, competitor_b_team=human_team_b, competitor_a_name='random', competitor_b_name='grodbot', config=config) results = competition.run(num_games=2) results.print()
import ffai import mybot import argparse import yaml parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--config', help='Configuration file for the competition', required=True) args = parser.parse_args() competition_config = yaml.safe_load(open(args.config, 'r')) # Load configurations, rules, arena and teams config = ffai.load_config(competition_config['config']) ruleset = ffai.load_rule_set(config.ruleset) arena = ffai.load_arena(config.arena) team_a = ffai.load_team_by_filename(competition_config['competitor-a']['team'], ruleset) team_b = ffai.load_team_by_filename(competition_config['competitor-b']['team'], ruleset) # Make proxy agents client_a = ffai.PythonSocketClient( competition_config['competitor-a']['name'], host=competition_config['competitor-a']['hostname'], port=competition_config['competitor-a']['port'], token=competition_config['competitor-a']['token']) client_b = ffai.PythonSocketClient( competition_config['competitor-b']['name'],
dict_o = vars(o) for k in dict_o: print(k, " - ", dict_o[k]) def print_dict(d): for k in d: print(k, " - ", d[k]) pitch_size = 11 # Load configurations, rules, arena and teams #config = ffai.load_config("bot-bowl-ii") config = ffai.load_config("ff-" + str(pitch_size)) config.fast_mode = False config.competition_mode = False ruleset = ffai.load_rule_set(config.ruleset) arena = ffai.load_arena(config.arena) team1 = ffai.load_all_teams(ruleset, pitch_size)[0] team2 = ffai.load_all_teams(ruleset, pitch_size)[0] #env = ffai.FFAIEnv(config, team1, team2, opp_actor=opponent_bot) env = ffai.FFAIEnv(config, team1, team2) seed = 1315 env.seed(seed) #obs = env.step( get_random_action(env) )