Esempio n. 1
0
def main():
    # parse command line arguments to script
    args = parse_arguments()

    # interpret semantic meaning of arguments
    botfiles = args.botfiles
    uniform_map = args.uniform
    n_players = len(args.botfiles)
    iters = DEFAULT_ITERS if args.iters is None else int(args.iters)

    # structure:
    # wins[i] = n
    # encodes player with playerID i has n wins
    wins = {}

    for i in range(n_players):
        wins[i] = 0

    print_progress(0, iters)

    for i in range(iters):
        # set up bots by loading from source files
        bots = [LocalBot(arg, i) for (i, arg) in enumerate(botfiles)]

        # initialize the match
        game = Game(bots, uniform_map)

        # run the match
        game.start()

        # get the rankings from completed match
        winnerID = game.get_ranked_players()[0].get_ID()
        wins[winnerID] += 1

        # clean up after ourselves
        for bot in bots:
            bot.cleanup()

        # display progress
        print_progress(i + 1, iters)

    print("---------------PERFORMANCE REPORT---------------")
    for i in range(n_players):
        print("  Bot {}: {} wins".format(i, wins[i]))
    print("------------------------------------------------")