Пример #1
0
from utils import *

"""
use this script to play any two agents against each other, or play manually with
any agent.
"""

g = OthelloGame(6)

# all players
rp = RandomPlayer(g).play
gp = GreedyOthelloPlayer(g).play
hp = HumanOthelloPlayer(g).play

# nnet players
n1 = NNet(g)
n1.load_checkpoint('./pretrained_models/othello/pytorch/','6x100x25_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))


#n2 = NNet(g)
#n2.load_checkpoint('/dev/8x50x25/','best.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, hp, g, display=display)
print(arena.playGames(2, verbose=True))
Пример #2
0
any agent.
"""
with open('othello/book/XOT/openingssmall.txt') as my_file:
    book_array = my_file.readlines()

g = OthelloGame(8)

# all players
rp = RandomPlayer(g)
gp = GreedyOthelloPlayer(g)
hp = HumanOthelloPlayer(g)

edax = EdaxPlayer(3, g)

# nnet players
n1 = NNet(g)
n1.load_checkpoint('./temp/', 'restart.pth.tar')
#n1.load_checkpoint('./pretrained_models/othello/pytorch','restart.pth.tar')
args1 = dotdict({'numMCTSSims': 600, 'cpuct': 1.0})
n1p = NeuralPlayer(g, n1, args1)

n2 = NNet(g)
n2.load_checkpoint('./pretrained_models/othello/pytorch',
                   '8x8_100checkpoints_best.pth.tar')

args2 = dotdict({'numMCTSSims': 200, 'cpuct': 1.0})
n2p = NeuralPlayer(g, n2, args2, False)

arena = Arena.Arena(n1p, edax, g, display=display, book=book_array)
print(arena.playGames(10, verbose=True))
Пример #3
0
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 = OthelloGame(6)

# all players
rp = RandomPlayer(g).play
gp = GreedyOthelloPlayer(g).play
hp = HumanOthelloPlayer(g).play

# nnet players
n1 = NNet(g)
n1.load_checkpoint('./pretrained_models/', '6x100x25_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))

#n2 = NNet(g)
#n2.load_checkpoint('/dev/8x50x25/','best.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, hp, g, display=display)
print(arena.playGames(2, verbose=True))
Пример #4
0
    g = nimGame(config)

# all players
#rp = RandomPlayer(g).play

if gameChoice == 0:
    gp = GreedyOthelloPlayer(g).play
    hp = HumanOthelloPlayer(g).play
elif gameChoice == 1:
    hp = HumanTicTacToePlayer(g).play
elif gameChoice == 2:
    hp = HumanNimPlayer(g).play

# nnet players
if gameChoice == 0:
    n1 = NNet(g)
else:
    n1 = nn(g)

if gameChoice == 0:
    if mini_othello:
        n1.load_checkpoint('./pretrained_models/othello/pytorch/',
                           '6x100x25_best.pth.tar')
    else:
        n1.load_checkpoint('./pretrained_models/othello/pytorch/',
                           '8x8_100checkpoints_best.pth.tar')
elif gameChoice == 1:
    n1.load_checkpoint(
        '/Users/mettinger/github/alpha-zero-general/pretrained_models/tictactoe/keras',
        'best-25eps-25sim-10epch.pth.tar')
elif gameChoice == 2:
Пример #5
0
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 = OthelloGame()

# all players
rp = RandomPlayer(g).play
#gp = GreedyOthelloPlayer(g).play
hp = HumanOthelloPlayer(g).play

# nnet players
n1 = NNet(g)
n1.load_checkpoint('./temp/', 'checkpoint_2.pth.tar')
args1 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0})
mcts1 = MCTS(g, n1, args1)
n1p = lambda x: np.argmax(mcts1.getActionProb(x, temp=0))

#n2 = NNet(g)
#n2.load_checkpoint('/dev/8x50x25/','best.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, hp, g, display=display)
print(arena.playGames(2, verbose=True))
Пример #6
0
mini_othello = False  # Play in 6x6 instead of the normal 8x8.
human_vs_cpu = True

if mini_othello:
    g = OthelloGame(6)
else:
    g = OthelloGame(8)

# all players
rp = RandomPlayer(g).play
gp = GreedyOthelloPlayer(g).play
hp = HumanOthelloPlayer(g).play


# nnet players
n1 = NNet(g)
if mini_othello:
    n1.load_checkpoint('./pretrained_models/othello/pytorch/',
                       '6x100x25_best.h5')
else:
    n1.load_checkpoint('./pretrained_models/othello/pytorch/',
                       '8x8_100checkpoints_best.h5')
args1 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0})
mcts1 = MCTS(g, n1, args1)
def n1p(x): return np.argmax(mcts1.getActionProb(x, temp=0))


if human_vs_cpu:
    player2 = hp
else:
    n2 = NNet(g)