import Arena
from MCTS import MCTS
from Kamisado.KamisadoGame import KamisadoGame
from Kamisado.KamisadoPlayers import *
from Kamisado.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.
"""

 # Play in 6x6 instead of the normal 8x8.
human_vs_cpu = True

g = KamisadoGame(8)

# all players
'''p1 = HumanTicTacToePlayer(g).play
p2 = HumanTicTacToePlayer(g).play'''
rp = RandomPlayer(g).play
hp = HumanKamisadoPlayer(g).play
#arena = Arena.Arena(p1, p2, g, display=TicTacToeGame.display)
arena = Arena.Arena(hp, rp, g, display=KamisadoGame.display) # OthelloGame

print(arena.playGames(2, verbose=True))


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

if human_vs_cpu:
    player2 = hp
else:
    n2 = NNet(g)
    n2.load_checkpoint('./pretrained_models/othello/pytorch/', '8x8_100checkpoints_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))

    player2 = n2p  # Player 2 is neural network if it's cpu vs cpu.

arena = Arena.Arena(n1p, player2, g, display=KamisadoGame.display)

print(arena.playGames(2, verbose=True))
'''
import Arena
from MCTS import MCTS
from Kamisado.KamisadoGame import KamisadoGame
from Kamisado.KamisadoPlayers import *
from Kamisado.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.
"""

 # Play in 6x6 instead of the normal 8x8.
human_vs_cpu = True

g = KamisadoGame(8)

# all players
'''p1 = HumanTicTacToePlayer(g).play
p2 = HumanTicTacToePlayer(g).play'''
rp = RandomPlayer(g).play
hp = HumanKamisadoPlayer(g).play
#arena = Arena.Arena(p1, p2, g, display=TicTacToeGame.display)
arena = Arena.Arena(hp, rp, g, display=KamisadoGame.display) # OthelloGame

print(arena.playGames(2, verbose=True))


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

if human_vs_cpu:
    player2 = hp
else:
    n2 = NNet(g)
    n2.load_checkpoint('./pretrained_models/othello/pytorch/', '8x8_100checkpoints_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))

    player2 = n2p  # Player 2 is neural network if it's cpu vs cpu.

arena = Arena.Arena(n1p, player2, g, display=KamisadoGame.display)

print(arena.playGames(2, verbose=True))
'''
use this script to play any two agents against each other, or play manually with any agent. # Play in 6x6 instead of the normal 8x8. # all players p1 = HumanTicTacToePlayer(g).play p2 = HumanTicTacToePlayer(g).play #arena = Arena.Arena(p1, p2, g, display=TicTacToeGame.display) # OthelloGame # nnet players n1 = NNet(g)     n1.load_checkpoint('./pretrained_models/othello/pytorch/','8x8_100checkpoints_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))  if human_vs_cpu:     player2 = hp else:     n2 = NNet(g)     n2.load_checkpoint('./pretrained_models/othello/pytorch/', '8x8_100checkpoints_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))      player2 = n2p  # Player 2 is neural network if it's cpu vs cpu.  arena = Arena.Arena(n1p, player2, g, display=KamisadoGame.display)  print(arena.playGames(2, verbose=True))