Exemplo n.º 1
0
def run_game(dir1, dir2, board_size=16, max_rounds=250, debug=False):
    c1 = CodeContainer.from_directory(dir1)
    c2 = CodeContainer.from_directory(dir2)
    game = Game([c1, c2], board_size=board_size, max_rounds=max_rounds, debug=debug, seed=None)
    while game.running:
        game.turn()
    return game.winner.value
Exemplo n.º 2
0
def run_game(dir1,
             dir2,
             board_size=16,
             max_rounds=250,
             debug=False,
             random_pieces=0):
    c1 = CodeContainer.from_directory(dir1)
    c2 = CodeContainer.from_directory(dir2)
    game = Game([c1, c2],
                board_size=board_size,
                max_rounds=max_rounds,
                debug=debug,
                seed=None,
                random_pieces=random_pieces)
    while game.running:
        game.turn()
    return game.get_score()
Exemplo n.º 3
0
        bot2 = int(bot2)

    with open(f"saved_weights/epoch{epoch1}.json") as f:
        weights1 = json.load(f)[bot1]

    with open(f"saved_weights/epoch{epoch2}.json") as f:
        weights2 = json.load(f)[bot2]

    r1 = Robot("test1", weights1)
    r2 = Robot("test2", weights2)
    c1 = CodeContainer.from_directory(r1.bot_directory)
    c2 = CodeContainer.from_directory(r2.bot_directory)

    game = Game([c1, c2],
                board_size=16,
                max_rounds=MAX_ROUNDS,
                random_pieces=0,
                debug=True,
                seed=None)

    start = time.time()
    while game.running:
        print('.', end='', flush=True)
        game.turn()
    print()
    end = time.time()
    print(f"Winner is {game.winner}")
    print(f"Time taken = {end - start}")
    viewer = FancyViewer(game.board_size, game.board_states, window_size=800)
    viewer.play(delay=0.04)