コード例 #1
0
def test(args):
    c, n = args
    # settings
    RED, BLUE = 1, 2
    ai_algorithms = ['random', 'mc', 'mc_ucb1', 'uct', 'uct_wm']
    player1_type, player2_type, board_size = sys.argv[1:4]

    # init red player
    if player1_type in ai_algorithms:
        player1 = AI(RED, player1_type)
    else:
        raise TypeError("Wrong player 1 type ")

    # init blue player
    if player2_type in ai_algorithms:
        player2 = AI(BLUE, player2_type)
    else:
        raise Exception("Wrong player 2 type")

    if c != None:
        player2.explorationConstant = c

    board = Board(board_size)
    game = Game(board, player1, player2)
    winner = game.runNoDisplay()

    return winner