Exemplo n.º 1
0
import h5py
from dlgo.agent.predict import load_prediction_agent
from dlgo.httpfrontend.server import get_web_app

model_file = h5py.File("agents/deep_bot.h5", "r")
bot_from_file = load_prediction_agent(model_file)
web_app = get_web_app({'predict': bot_from_file})
web_app.run()
Exemplo n.º 2
0
from dlgo.agent.predict import DeepLearningAgent, load_prediction_agent
from dlgo.httpfrontend.server import get_web_app
import h5py
from dlgo import goboard_fast as goboard

model_file = h5py.File("agents/deep_bot.h5", "r")
deep_bot = load_prediction_agent(model_file)
deep_bot.model._make_predict_function()
web_app = get_web_app({'predict': deep_bot})
web_app.run()
from dlgo.agent.naive import RandomBot
from dlgo.httpfrontend.server import get_web_app

random_agent = RandomBot()
web_app = get_web_app({'random': random_agent})
web_app.run()
Exemplo n.º 4
0
from dlgo.agent.naive import RandomBot
from dlgo.agent import load_prediction_agent
from dlgo.httpfrontend.server import get_web_app
import h5py

bots = {}
random_agent = RandomBot()
# bot_agent = load_prediction_agent(h5py.File("agents/GHGHbot1_rl_policy.h5", "r"))
bot_agent = load_prediction_agent(h5py.File('agents/deep_bot_2.h5', "r"))
web_app = get_web_app({'random': random_agent, 'predict': bot_agent})
web_app.run(threaded=False)
Exemplo n.º 5
0
def main():
    print("******************************************************************")
    print("*                                                                *")
    print("*    <3 <3 <3 <3 <3     WELCOME TO GAME GO     <3 <3 <3 <3 <3    *")
    print("*                                                                *")
    print("******************************************************************")
    print("*                                                                *")
    print("*         1. Play game on terminal                               *")
    print("*                                                                *")
    print("*             a. Human vs Bot AlphaBeta on Board 9x9             *")
    print("*             b. Human vs Bot Depthprune on Board 9x9            *")
    print("*             c. Human vs Bot MCTS on Board 9x9                  *")
    print("*             d. Bot AlphaBeta vs Bot MCTS on Board 9x9          *")
    print("*                                                                *")
    print("*         2. Play game on web                                    *")
    print("*                                                                *")
    print("*             a. Human vs Bot MCTS on Board 9x9                  *")
    print("*             b. Human vs Bot DeepLearning on Board 19x19        *")
    print("*                                                                *")
    print("******************************************************************")
    print("                                                                  ")
    print("            *****************************************             ")
    print("                                                                  ")
    choices_A = int(input("                     Choose Terminal or Web: "))
    choices_B = input("                         Choose type bot: ")
    print("                                                                  ")
    print("            *****************************************             ")
    BOARD_SIZE = 9
    game = goboard.GameState.new_game(BOARD_SIZE)

    if choices_A == 1:
        if choices_B == 'a':
            bot = minimax.AlphaBetaAgent(4, capture_diff)
        if choices_B == 'b':
            bot = minimax.DepthPrunedAgent(4, capture_diff)
        if choices_B == 'c':
            bot = mcts.MCTSAgent(500, temperature=1.4)
        if choices_B == 'd':
            bots = {
                gotypes.Player.black: minimax.AlphaBetaAgent(4, capture_diff),
                gotypes.Player.white: mcts.MCTSAgent(500, temperature=1.4),
            }
            while not game.is_over():
                time.sleep(0.3)
                print_board(game.board)
                bot_move = bots[game.next_player].select_move(game)
                print_move(game.next_player, bot_move)
                game = game.apply_move(bot_move)

        if choices_B == 'a' or choices_B == 'b' or choices_B == 'c':
            while not game.is_over():
                print_board(game.board)
                if game.next_player == gotypes.Player.black:
                    human_move = input('-- ')
                    point = point_from_coords(human_move.strip())
                    move = goboard.Move.play(point)
                else:
                    move = bot.select_move(game)
                print_move(game.next_player, move)
                game = game.apply_move(move)
    else:
        if choices_B == 'a':
            bot = mcts.MCTSAgent(700, temperature=1.4)
            web_app = get_web_app({'mcts': bot})
            web_app.run()