def evaluate_players(p1: Player,
                     p2: Player,
                     games_per_battle=100,
                     num_battles=100,
                     randomize: bool = False,
                     p1_name: str = 'Player 1',
                     p2_name: str = 'Player2'):

    board = Board()

    p1_wins = []
    p2_wins = []
    draws = []
    game_number = []
    game_counter = 0

    TFSessionManager.set_session(tf.Session())
    TFSessionManager.get_session().run(tf.global_variables_initializer())

    for i in range(num_battles):
        # Allows randomization for training full model.
        first_play = bool(random.getrandbits(1))
        if not randomize or first_play:
            p1win, p2win, draw = battle(p1, p2, games_per_battle)
        else:
            p2win, p1win, draw = battle(p2, p1, games_per_battle)
        p1_wins.append(p1win)
        p2_wins.append(p2win)
        draws.append(draw)
        game_counter = game_counter + 1
        game_number.append(game_counter)

    TFSessionManager.set_session(None)
    return game_number, p1_wins, p2_wins, draws
Esempio n. 2
0
def evaluate_players(p1: Player,
                     p2: Player,
                     games_per_battle=100,
                     num_battles=100):
    board = Board()

    p1_wins = []
    p2_wins = []
    draws = []
    game_number = []
    game_counter = 0

    TFSessionManager.set_session(tf.Session())
    TFSessionManager.get_session().run(tf.global_variables_initializer())

    for i in range(num_battles):
        p1win, p2win, draw = battle(p1, p2, games_per_battle, False)
        p1_wins.append(p1win)
        p2_wins.append(p2win)
        draws.append(draw)
        game_counter = game_counter + 1
        game_number.append(game_counter)

    TFSessionManager.set_session(None)
    return game_number, p1_wins, p2_wins, draws
Esempio n. 3
0
p1_wins = []
p1count = 0
p2_wins = []
p2count = 0
draws = []
drawcount = 0
count = []
num_battles = 100
games_per_battle = 10

TFSessionManager.set_session(tf.Session())
TFSessionManager.get_session().run(tf.global_variables_initializer())

for i in range(num_battles):
    p1win, p2win, draw = battle(player1, player2, games_per_battle, True)
    p1_wins.append(p1win)
    p1count += p1win
    p2_wins.append(p2win)
    p2count += p2win
    draws.append(draw)
    drawcount += draw
    count.append(i * games_per_battle)
#TFSessionManager.set_session(None)
p = plt.plot(count, draws, 'r-', count, p1_wins, 'g-', count, p2_wins, 'b-')
print("p1 wins = " + str(p1count / (num_battles * games_per_battle) * 100) +
      "% (green)")
print("p2 wins = " + str(p2count / (num_battles * games_per_battle) * 100) +
      "% (blue)")
print("ties = " + str(drawcount / (num_battles * games_per_battle) * 100) +
      "% (red)")
Esempio n. 4
0
TFSessionManager.get_session().run(tf.global_variables_initializer())
writer = tf.summary.FileWriter('log', TFSessionManager.get_session().graph)

# nnplayer rndplayer mm_player
p1_t = deep_nnplayer
p2_t = mm_player

p1 = p1_t
p2 = p2_t

# nnplayer.training= False
# nnplayer2.training= False

for i in range(num_training_battles):
    p1win, p2win, draw = battle(p1_t, p2_t, games_per_battle, False)
    p1_wins.append(p1win)
    p2_wins.append(p2win)
    draws.append(draw)
    game_counter = game_counter + 1
    game_number.append(game_counter)

# nnplayer.training= False
# nnplayer2.training= False

for i in range(num_battles):
    p1win, p2win, draw = battle(p1, p2, games_per_battle, False)
    p1_wins.append(p1win)
    p2_wins.append(p2win)
    draws.append(draw)
    game_counter = game_counter + 1