Exemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--bind-address', default='127.0.0.1')
    parser.add_argument('--port', '-p', type=int, default=5000)
    parser.add_argument('--pg-agent')
    parser.add_argument('--predict-agent')
    parser.add_argument('--q-agent')
    parser.add_argument('--ac-agent')

    args = parser.parse_args()

    bots = {'mcts': mcts.MCTSAgent(800, temperature=0.7)}
    if args.pg_agent:
        bots['pg'] = agent.load_policy_agent(h5py.File(args.pg_agent))
    if args.predict_agent:
        bots['predict'] = agent.load_prediction_agent(
            h5py.File(args.predict_agent))
    if args.q_agent:
        q_bot = rl.load_q_agent(h5py.File(args.q_agent))
        q_bot.set_temperature(0.01)
        bots['q'] = q_bot
    if args.ac_agent:
        ac_bot = rl.load_ac_agent(h5py.File(args.ac_agent))
        ac_bot.set_temperature(0.05)
        bots['ac'] = ac_bot

    web_app = httpfrontend.get_web_app(bots)
    web_app.run(host=args.bind_address, port=args.port, threaded=False)
Exemplo n.º 2
0
def main():
    workdir = '//home/nail//Code_Go//checkpoints//'
    os.chdir(workdir)
    bind_address = '127.0.0.1'
    port = 5000
    predict_agent, pg_agent, q_agent, ac_agent = '', '', '', ''
    agent_type = input('Агент(pg/predict/q/ac = ').lower()
    if agent_type == 'pg':
        pg_agent = input(
            'Введите имя файла для игры с ботом политика градиентов =')
        pg_agent = workdir + pg_agent + '.h5'
    if agent_type == 'predict':
        predict_agent = input(
            'Введите имя файла для игры с ботом предсказания хода =')
        predict_agent = workdir + predict_agent + '.h5'
    if agent_type == 'q':
        q_agent = input(
            'Введите имя файла для игры с ботом ценность действия =')
        q_agent = workdir + q_agent + '.h5'
    if agent_type == 'ac':
        ac_agent = input('Введите имя файла для игры с ботом актор-критик =')
        ac_agent = workdir + ac_agent + '.h5'

    bots = {'mcts': mcts.MCTSAgent(800, temperature=0.7)}
    if agent_type == 'pg':
        bots['pg'] = agent.load_policy_agent(h5py.File(pg_agent, 'r'))
    if agent_type == 'predict':
        bots['predict'] = agent.load_prediction_agent(
            h5py.File(predict_agent, 'r'))
    if agent_type == 'q':
        q_bot = rl.load_q_agent(h5py.File(q_agent, 'r'))
        q_bot.set_temperature(0.01)
        bots['q'] = q_bot
    if agent_type == 'ac':
        ac_bot = rl.load_ac_agent(h5py.File(ac_agent, 'r'))
        ac_bot.set_temperature(0.05)
        bots['ac'] = ac_bot

    web_app = httpfrontend.get_web_app(bots)
    web_app.run(host=bind_address, port=port, threaded=False)
Exemplo n.º 3
0
# tag::run_alphago[]
from dlgo.agent import load_prediction_agent, load_policy_agent, AlphaGoMCTS
from dlgo.rl import load_value_agent
import h5py

fast_policy = load_prediction_agent(h5py.File('alphago_sl_policy.h5', 'r'))
strong_policy = load_policy_agent(h5py.File('alphago_rl_policy.h5', 'r'))
value = load_value_agent(h5py.File('alphago_value.h5', 'r'))

alphago = AlphaGoMCTS(strong_policy, fast_policy, value)
# end::run_alphago[]

# TODO: register in frontend
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
from dlgo.agent import load_prediction_agent, load_policy_agent, AlphaGoMCTS
from dlgo.rl import load_value_agent
import h5py

fast_policy = load_prediction_agent(h5py.File('agents/GHGHbot1_sl_policy.h5', 'r'))
strong_policy = load_policy_agent(h5py.File('agents/GHGHbot1_rl_policy.h5', 'r'))
value = load_value_agent(h5py.File('agents/GHGHbot1_value.h5', 'r'))

alphago = AlphaGoMCTS(strong_policy, fast_policy, value)


# TODO: register in frontend