-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ai.py
More file actions
32 lines (23 loc) · 761 Bytes
/
test_ai.py
File metadata and controls
32 lines (23 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import tensorflow as tf
from othello import *
from mcts import MCTS, selfplay, play_game, faceoff
from alphello_net import Othello_Network as ONET
from tqdm import tqdm, trange
if __name__ == '__main__':
game = Othello()
board = game.board
player = game.player
playing_net = ONET(n_filters=128, n_res=3)
training_net = ONET(n_filters=128, n_res=3)
training_net.load_weights()
winners = []
for k in trange(10):
if k < 5:
winners.append(-play_game(training_net, playing_net, mcts_iters=100))
else:
winners.append(play_game(playing_net, training_net, mcts_iters=100))
# Calculate win rate
win_rate = np.mean(winners)
print(win_rate)
print(winners)