from utils.alphaNNet import AlphaNNet from utils.agent import Agent from utils.game import Game from player import Player height = 11 width = 11 snake_cnt = 4 competeEps = 3 file_name = input("\nEnter the model name:\n") net = AlphaNNet(model="models/" + file_name + ".h5") net.v_net.summary() agent = Agent(net) f = open("replay.rep", 'w') f.write('') f.close() print("Running games...") for _ in range(competeEps): g = Game(height, width, snake_cnt) g.run(agent, show=True) n = input("\nHit Enter to watch replay") Player().main()
snake_cnt = 4 competeEps = 128 file_name1 = input("\nEnter the model 1 name:\n") file_name2 = input("\nEnter the model 2 name:\n") nnet1 = AlphaNNet(model="models/" + file_name1 + ".h5") nnet2 = AlphaNNet(model="models/" + file_name2 + ".h5") Alice = Agent(nnet1) Bob = Agent(nnet2) win = 0 draw = 0 t0 = time() for _ in range(competeEps): g = Game(height, width, snake_cnt) winner_id = g.run(Alice, Bob, 1) if winner_id is None: draw += 1 elif winner_id < 1: win += 1 print("1v3 WR of", file_name1, win / (competeEps), "DR =", draw / (competeEps)) print("Competing time", time() - t0) win = 0 draw = 0 t0 = time() for _ in range(competeEps): g = Game(height, width, snake_cnt) winner_id = g.run(Bob, Alice, 1) if winner_id is None: draw += 1
def main(): game = Game(BLACK, RES) game.run()