action_choice.players) if len(action_choice.players) > 0 else None # Make action object action = ffai.Action(action_choice.action_type, position=position, player=player) # Return action to the framework return action def end_game(self, game): pass # Register the bot to the framework ffai.register_bot('my-random-bot', MyRandomBot) if __name__ == "__main__": # Load configurations, rules, arena and teams config = ffai.load_config("bot-bowl-ii") ruleset = ffai.load_rule_set(config.ruleset) arena = ffai.load_arena(config.arena) home = ffai.load_team_by_filename("human", ruleset) away = ffai.load_team_by_filename("human", ruleset) config.competition_mode = False config.debug_mode = False # Play 10 games game_times = [] for i in range(10):
Called when a game endw. """ winner = game.get_winning_team() print("Casualties: ", game.num_casualties()) if winner is None: print("It's a draw") elif winner == self.my_team: 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)
print( f"{best_node.action.action_type} selected in {time.time() - t} seconds" ) return best_node.action def _evaluate(self, game): return random.random() def end_game(self, game): pass # Register the bot to the framework ffai.register_bot('search-bot', SearchBot) # Load configurations, rules, arena and teams config = ffai.load_config("bot-bowl-iii") ruleset = ffai.load_rule_set(config.ruleset) arena = ffai.load_arena(config.arena) home = ffai.load_team_by_filename("human", ruleset) away = ffai.load_team_by_filename("human", ruleset) config.competition_mode = False config.debug_mode = False config.fast_mode = True config.pathfinding_enabled = False # Play a game bot_a = ffai.make_bot("search-bot") bot_b = ffai.make_bot("search-bot")