Skip to content

Commit

Permalink
updated tests, all but Connect4 pass
Browse files Browse the repository at this point in the history
  • Loading branch information
suragnair committed Jun 19, 2022
1 parent 10584ff commit 1db83a7
Showing 1 changed file with 47 additions and 38 deletions.
85 changes: 47 additions & 38 deletions test_all_games.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,52 @@
plays two quick games using an untrained neural network (randomly initialized) against a random player.
In order for the entire test suite to run successfully, all the required libraries must be installed. They are:
Pytorch, Keras, Tensorflow.
[ Games ] Pytorch Tensorflow Keras
----------- ------- ---------- -----
- Othello [Yes] [Yes] [Yes]
- TicTacToe [Yes]
- Connect4 [Yes]
- Gobang [Yes] [Yes]
- Santorini [Yes]
Pytorch, Keras.
[ Games ] Pytorch Keras
----------- ------- -----
- Othello [Yes] [Yes]
- TicTacToe [Yes]
- TicTacToe3D [Yes]
- Connect4 [Yes]
- Gobang [Yes]
- Tafl [Yes] [Yes]
- Rts [Yes]
- DotsAndBoxes [Yes]
"""

import unittest

import Arena
from MCTS import MCTS

from othello.OthelloGame import OthelloGame
from othello.OthelloPlayers import RandomPlayer
from othello.pytorch.NNet import NNetWrapper as OthelloPytorchNNet
from othello.keras.NNet import NNetWrapper as OthelloKerasNNet

from tictactoe.TicTacToeGame import TicTacToeGame
from tictactoe.TicTacToePlayers import *
from tictactoe.keras.NNet import NNetWrapper as TicTacToeKerasNNet

from tictactoe_3d.TicTacToeGame import TicTacToeGame as TicTacToe3DGame
from tictactoe_3d.TicTacToePlayers import *
from tictactoe_3d.keras.NNet import NNetWrapper as TicTacToe3DKerasNNet

from othello.OthelloGame import OthelloGame
from othello.OthelloPlayers import *
#from othello.pytorch.NNet import NNetWrapper as OthelloPytorchNNet
from othello.tensorflow.NNet import NNetWrapper as OthelloTensorflowNNet
from othello.keras.NNet import NNetWrapper as OthelloKerasNNet

from connect4.Connect4Game import Connect4Game
from connect4.Connect4Players import *
from connect4.tensorflow.NNet import NNetWrapper as Connect4TensorflowNNet
from connect4.keras.NNet import NNetWrapper as Connect4KerasNNet

from gobang.GobangGame import GobangGame
from gobang.GobangPlayers import *
from gobang.keras.NNet import NNetWrapper as GobangKerasNNet
from gobang.tensorflow.NNet import NNetWrapper as GobangTensorflowNNet

from santorini.SantoriniGame import SantoriniGame
from santorini.SantoriniPlayers import *
from santorini.tensorflow.NNet import NNetWrapper as SantoriniTensorflowNNet
from tafl.TaflGame import TaflGame
from tafl.pytorch.NNet import NNetWrapper as TaflPytorchNNet
from tafl.keras.NNet import NNetWrapper as TaflKerasNNet

from rts.RTSGame import RTSGame
from rts.keras.NNet import NNetWrapper as RTSKerasNNet

from dotsandboxes.DotsAndBoxesGame import DotsAndBoxesGame
from dotsandboxes.keras.NNet import NNetWrapper as DotsAndBoxesKerasNNet

import numpy as np
from utils import *

Expand All @@ -62,30 +65,36 @@ def execute_game_test(game, neural_net):

arena = Arena.Arena(n1p, rp, game)
print(arena.playGames(2, verbose=False))

def test_othello_pytorch(self):
self.execute_game_test(OthelloGame(6), OthelloPytorchNNet)

def test_othello_tensorflow(self):
self.execute_game_test(OthelloGame(6), OthelloTensorflowNNet)

def test_othello_keras(self):
self.execute_game_test(OthelloGame(6), OthelloKerasNNet)

def test_tictactoe_keras(self):
self.execute_game_test(TicTacToeGame(), TicTacToeKerasNNet)

def test_connect4_tensorflow(self):
self.execute_game_test(Connect4Game(), Connect4TensorflowNNet)

def test_tictactoe3d_keras(self):
self.execute_game_test(TicTacToe3DGame(3), TicTacToe3DKerasNNet)
def test_gobang_keras(self):
self.execute_game_test(GobangGame(), GobangKerasNNet)

def test_gobang_tensorflow(self):
self.execute_game_test(GobangGame(), GobangTensorflowNNet)
def test_tafl_pytorch(self):
self.execute_game_test(TaflGame(5), TaflPytorchNNet)

def test_tafl_keras(self):
self.execute_game_test(TaflGame(5), TaflKerasNNet)

def test_connect4_keras(self):
self.execute_game_test(Connect4Game(5), Connect4KerasNNet)

def test_rts_keras(self):
self.execute_game_test(RTSGame(), RTSKerasNNet)

def test_santorini_tensorflow(self):
self.execute_game_test(SantoriniGame(5), SantoriniTensorflowNNet)
def test_dotsandboxes_keras(self):
self.execute_game_test(DotsAndBoxesGame(3), DotsAndBoxesKerasNNet)

if __name__ == '__main__':
unittest.main()
unittest.main()

0 comments on commit 1db83a7

Please sign in to comment.