forked from edwardchu-studio/alpha-zero-general-with-Go-game
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
52 lines (43 loc) · 1.19 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
50
51
52
from GoCoach import Coach
from go.GoGame import GoGame as Game
from go.pytorch.NNet import NNetWrapper as nn
from utils import *
import os,sys
from enum import Enum
sys.setrecursionlimit(5000)
class Display(Enum):
NO_DISPLAY = 0
DISPLAY_BAR = 1
DISPLAY_BOARD = 2
BoardSize=7
NetType='CNN' # or 'RES'
tag='MCTS_SimModified'
args = dotdict({
'numIters': 1000,
'numEps': 100,
'tempThreshold': 15,
'updateThreshold': 0.54,
'maxlenOfQueue': 200000,
'numMCTSSims': 200,
'arenaCompare': 50,
'cpuct': 3,
'checkpoint': './logs/go/{}_checkpoint/{}/'.format(NetType + '_' + tag, BoardSize),
'load_model': False,
'numItersForTrainExamplesHistory': 25,
'display': Display.DISPLAY_BOARD
})
if __name__=="__main__":
g = Game(BoardSize)
nnet = nn(g, t=NetType)
logPath='./logs/go/{}_log/{}/'.format(NetType + '_' + tag, BoardSize)
try:
os.makedirs(logPath)
except:
pass
if args.load_model:
nnet.load_checkpoint(args.checkpoint, 'best.pth.tar')
c = Coach(g, nnet, args, log=True, logPath=logPath)
if args.load_model:
print("Loading trainExamples from file")
c.loadTrainExamples()
c.learn()