Example #1
0
 def test_random(self):
     player_blue = RandomPlayer(Color.BLUE)
     player_red = RandomPlayer(Color.RED)
     board = Board()
     game = Game(player_blue, player_red, board)
     game.run_game(200)
     print(repr(board))
     print(board)
     print(game.get_winner())
Example #2
0
 def test_stockfish(self):
     board = get_random_board()
     process = get_process_stockfish(board, "level 40 5 0")
     player_blue = StockfishPlayer(Color.BLUE, process, think_time=-1)
     player_red = StockfishPlayer(Color.RED, process, think_time=-1)
     game = Game(player_blue, player_red, board)
     winner = game.run_game(200)
     print(winner)
     print(repr(game.board))
def fight(player_blue, player_red, iter_max, print_board=False):
    board = get_random_board()
    game = Game(player_blue, player_red, board)
    winner = game.run_game(iter_max, print_board=print_board)
    print("Winner:", winner)
    print("Score BLUE:", board.get_score(Color.BLUE))
    print("Score RED:", board.get_score(Color.RED))
    print(repr(board))
    print(board)
    print(game.to_uci_usi())
    return winner
Example #4
0
 def test_random_vs_random(self):
     n_simulations = 400
     node = MCTSNode()
     player_blue = RandomMCTSPlayer(Color.BLUE,
                                    n_simulations=n_simulations,
                                    current_node=node)
     player_red = RandomMCTSPlayer(Color.RED,
                                   n_simulations=n_simulations,
                                   current_node=node)
     # winner = fight(player_blue, player_red, 200)
     board = get_random_board()
     game = Game(player_blue, player_red, board)
     winner = game.run_game(200)
     self.assertIn(winner, [Color.BLUE, Color.RED])
     print(game.to_json(node))