-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain4 (1).py
96 lines (67 loc) · 2.34 KB
/
main4 (1).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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 5 21:22:35 2021
@author: Victor
"""
import logging
#import coloredlogs
import logging
import math
import chessgame4
import numpy as np
from utils4 import *
import wrapper4
import sys
from Coach4 import Coach
from utils import *
log = logging.getLogger(__name__)
#coloredlogs.install(level='INFO') # Change this to DEBUG to see more info.
args = dotdict({
'numIters': 1000,
'numEps': 100, # Number of complete self-play games to simulate during a new iteration.
'tempThreshold': 15, #
'updateThreshold': 0.2875, # During arena playoff, new neural net will be accepted if threshold or more of games are won.
'maxlenOfQueue': 200000, # Number of game examples to train the neural networks.
'numMCTSSims': 15, # Number of games moves for MCTS to simulate.
'arenaCompare': 20, # Number of games to play during arena play to determine if new net will be accepted.
'cpuct': 1,
'checkpoint': '/content/drive/MyDrive/chess/',
'load_model': True,
'load_folder_file': ('/content/drive/MyDrive/chess/','best.pth.tar'),
'numItersForTrainExamplesHistory': 20,
})
def main():
#log.info('Loading %s...', Game.__name__)
#log.info('Loading %s...', nn.__name__)
nnet = wrapper4.NNetWrapper(game)
if True:
log.info('Loading checkpoint "%s/%s"...', args.load_folder_file)
nnet.load_checkpoint(args.load_folder_file[0], args.load_folder_file[1])
print('loaded model..........')
else:
log.warning('Not loading a checkpoint!')
log.info('Loading the Coach...')
c = Coach(game, nnet, args)
if False:
log.info("Loading 'trainExamples' from file...")
c.loadTrainExamples(15)
log.info('Starting the learning process 🎉')
c.learn()
if __name__ == "__main__":
game = chessgame4.GameBoard()
game.addpiece("wknight1", 1, 3,0)
game.addpiece("wknight2", 1, 3,1)
game.addpiece("wknight3", 1, 3,2)
game.addpiece("wknight4", 1, 3,3)
game.addpiece("bknight1", -1, 0,0)
game.addpiece("bknight2", -1, 0,1)
game.addpiece("bknight3", -1, 0,2)
game.addpiece("bknight4", -1, 0,3)
args2 = dict({
'lr': 0.001,
'dropout': 0.3,
'epochs': 40,
'batch_size': 64,
'num_channels': 512,
})
main()