-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (39 loc) · 1.17 KB
/
main.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
import time
import copy
from mcts_player import MCTSPlayer
from policy_value_net import PolicyValueNet
from board import Board
from game import Game
from players import HumanPlayer
from train import train
from smart_server import SmartServer
import config
board_n = config.board_config['board_n']
win = config.board_config['win']
model_filename = "first_model_" + str(board_n) + '_' +str(win) + '.h5'
def simple_train():
#board = Board(board_n, win)
#game = Game()
pvnet = PolicyValueNet(board_n, model_filename)
#mcts_player = MCTSPlayer(pvnet.get_pvnet_fn())
#bh, ph, vh = game.selfplay(board, mcts_player)
#bh, ph, vh = game.selfplay(board, HumanPlayer())
#print(vh)
while True:
train(pvnet, config.train_config['train_samples'])
pvnet.save_model(model_filename)
def smart_worker_train():
pvnet = PolicyValueNet(board_n, model_filename)
server = SmartServer(pvnet)
#print("Training")
#server.train_fn(*server.mem.get_history())
#print("Done")
while True:
server.train()
pvnet.save_model(model_filename)
def main():
#simple_train()
smart_worker_train()
if __name__ == "__main__":
main()