-
Notifications
You must be signed in to change notification settings - Fork 0
/
pit2.py
40 lines (30 loc) · 1.01 KB
/
pit2.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
import Arena
from MCTS import MCTS
from connect4.Connect4Players import *
from connect4.Connect4Game import Connect4Game, display
from connect4.tensorflow.NNet import NNetWrapper as nn
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 = Connect4Game()
# all players
rp = RandomPlayer(g).play
op = OneStepLookaheadConnect4Player(g).play
hp = HumanConnect4Player(g).play
mnp = MinimaxConnect4Player(g,3).play
#nnet players
n1 = nn(g)
n1.load_checkpoint('./model','checkpoint_59.pth.tar')
args1 = dotdict({'numMCTSSims': 25, 'cpuct':1.0})
mcts1 = MCTS(g, n1, args1)
n1p = lambda x: np.argmax(mcts1.getActionProb(x, temp=0))
# n2 = nn(g)
# n2.load_checkpoint('./model','checkpoint_2.pth.tar')
# args2 = dotdict({'numMCTSSims': 25, 'cpuct':1.0})
# mcts2 = MCTS(g, n2, args2)
# n2p = lambda x: np.argmax(mcts2.getActionProb(x, temp=0))
arena = Arena.Arena(n1p, rp, g, display=g.display_pygame)
print(arena.playGames(40, verbose=True))