def verify_bot_existance(configuration): for team_name, bot_name in configuration['teams'].items(): try: get_bot(bot_name) except: raise ValueError( f"Team {team_name} has an invalid bot: {bot_name}")
async def game_request_handler(websocket, path): if black == "human" and white == "human": print(f"Initializing human vs human session") await human_vs_human_session(websocket) elif black != "human" and white != "human": print("Initializing bot vs bot session") BlackBot = get_bot(black) WhiteBot = get_bot(white) await bot_vs_bot_session( websocket, BlackBot("black"), WhiteBot("white"), minimum_delay=1 ) else: print(f"Initializing human vs bot session") is_bot_black = black != "human" bot_name = black if is_bot_black else white Bot = get_bot(bot_name) await human_vs_bot_session( websocket, is_bot_black, Bot("black" if is_bot_black else "white"), minimum_delay=1 )
async def __play_tournament_game(websockets, black_bot_name, white_bot_name): BlackBot = get_bot(black_bot_name) WhiteBot = get_bot(white_bot_name) score = await bot_vs_bot_session(websockets, BlackBot("black"), WhiteBot("white"), minimum_delay=1) return score
async def __play_tournament_game(black_bot_name, white_bot_name): BlackBot = get_bot(black_bot_name) WhiteBot = get_bot(white_bot_name) score = await bot_vs_bot_session(None, BlackBot("black"), WhiteBot("white"), minimum_delay=0, headless=True) return score
async def game_session(): print("Initializing headless bot vs bot session") BlackBot = get_bot(black) WhiteBot = get_bot(white) await bot_vs_bot_session(None, BlackBot("black"), WhiteBot("white"), minimum_delay=0, headless=True)