forked from suragnair/alpha-zero-general
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpit.py
More file actions
69 lines (58 loc) · 2.2 KB
/
Copy pathpit.py
File metadata and controls
69 lines (58 loc) · 2.2 KB
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
import Arena
from MCTS import MCTS
from chess.ChessGame import ChessGame, display
from chess.ChessPlayers import *
#from chess.keras.NNet import NNetWrapper as NNet
import numpy as np
from utils import *
"""
use this script to play any two agents against each other, or play manually with
any agent.
"""
g = ChessGame()
# all players
rp = RandomPlayer(g).play
#gp = GreedyOthelloPlayer(g).play
#hp = HumanChessPlayer(g).play
#abp = AlphaBetaPlayer(g).play
# nnet players
#n1 = NNet(g)
#n1.load_checkpoint('temp/','checkpoint_1.pth.tar')
#n2 = NNet(g)
#n2.load_checkpoint('temp/','checkpoint_2.pth.tar')
#n3 = NNet(g)
#n3.load_checkpoint('temp/','checkpoint_3.pth.tar')
#n4 = NNet(g)
#n4.load_checkpoint('temp/','checkpoint_4.pth.tar')
#n5 = NNet(g)
#n5.load_checkpoint('temp/','checkpoint_5.pth.tar')
#example_file = 'temp/checkpoint_4.pth.tar.examples'
#networks = [n1, n2,n3, n4,n5]
#ensemble_player = EnsemblePlayer(g,networks,example_file).play
#args1 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0})
#mcts1 = MCTS(g, n1, args1)
#n1p = lambda x: np.argmax(mcts1.getActionProb(x, temp=0))
# #n1p = lambda x: np.argmax(n1.predict(x))
#n2 = NNet(g)
#n2.load_checkpoint('/home/jason/alpha-zero-general/temp/','temp.pth.tar')
#args2 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0})
#mcts2 = MCTS(g, n2, args2)
#n2p = lambda x: np.argmax(mcts2.getActionProb(x, temp=0))
#arena = Arena.Arena(rp, rp, g, display=display)
#print(arena.playGames(100, verbose=False))
# n1 = NNet(g)
# n1.load_checkpoint('saves/save-bc5a3cffa65','best.pth.tar')
# args1 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0})
# mcts1 = MCTS(g, n1, args1)
# n1p = lambda x: np.argmax(mcts1.getActionProb(x, temp=0))
n1 = NNetPlayer(g, "saves/save-bc5a3cffa65", "best.pth.tar", { 'numMCTSSims': 500, 'cpuct': 1.0, 'temp': 0 })
n1p = n1.play
# n2 = NNet(g)
# n2.load_checkpoint('saves/save-bc5a3cffa65','best.pth.tar')
# args2 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0})
# mcts2 = MCTS(g, n2, args2)
# n2p = lambda x: np.argmax(mcts2.getActionProb(x, temp=0))
#n2 = NNetPlayer(g, "saves/save-bc5a3cffa65", "best.pth.tar", { 'numMCTSSims': 50, 'cpuct': 1.0, 'temp': 0 })
#n2p = n2.play
arena = Arena.Arena(n1p, rp, g, display=display, num_workers=1)
arena.playGames(100, verbose=True)