Esempio n. 1
0
def command_line_parser():
    """Entry function"""
    args = docopt(__doc__)
    if args['--log']:
        logfile = args['--log']
    else:
        print("Using default log file")
        logfile = 'default'
    screenloglevel = logging.INFO if not args['--screenloglevel'] else \
        getattr(logging, args['--screenloglevel'].upper())
    _ = get_config()
    init_logger(screenlevel=screenloglevel, filename=logfile)
    print(f"Screenloglevel: {screenloglevel}")
    log = logging.getLogger("")
    log.info("Initializing program")

    num_eposodes = 1 if not args['--episodes'] else int(args['--episodes'])
    runner = Runner(render=args['--render'], num_episodes=num_eposodes)

    if args['random']:
        runner.random_agents()

    elif args['keypress']:
        runner.key_press_agents()

    elif args['consider_equity']:
        runner.equity_vs_random()

    elif args['equity_improvement']:
        improvement_rounds = int(args['--improvement_rounds'])
        runner.equity_self_improvement(improvement_rounds)

    else:
        raise RuntimeError("Agrument not yet implemented")
Esempio n. 2
0
def command_line_parser():
    """Entry function"""
    args = docopt(__doc__)
    if args['--log']:
        logfile = args['--log']
    else:
        print("Using default log file")
        logfile = 'default'
    model_name = args['--name'] if args['--name'] else 'dqn1'
    env_name = args['--env'] if args['--env'] else 'v0'
    screenloglevel = logging.INFO if not args['--screenloglevel'] else \
        getattr(logging, args['--screenloglevel'].upper())
    _ = get_config()
    init_logger(screenlevel=screenloglevel, filename=logfile)
    print(f"Screenloglevel: {screenloglevel}")
    log = logging.getLogger("")
    log.info("Initializing program")

    if args['selfplay']:
        num_episodes = 1 if not args['--episodes'] else int(args['--episodes'])
        agent = args['--agent'] if args['--agent'] else None
        players = eval(args['--players']) if args['--players'] else [0]
        load = args['--load'] if args['--load'] else False
        render = args['--render']
        use_cpp_montecarlo = args['--use_cpp_montecarlo']
        funds_plot = args['--funds_plot']

        print(args)
        runner = SelfPlay(render, num_episodes,
                          use_cpp_montecarlo,
                          funds_plot,
                          model_name, agent, env_name,
                          players,
                          load,
                          stack=int(args['--stack']))

        if args['random']:
            runner.random_agents()

        elif args['keypress']:
            runner.key_press_agents()

        elif args['consider_equity']:
            runner.equity_vs_random()

        elif args['equity_improvement']:
            improvement_rounds = int(args['--improvement_rounds'])
            runner.equity_self_improvement(improvement_rounds)

        elif args['dqn_train']:
            runner.dqn_agent('train')

        elif args['dqn_play']:
            runner.dqn_agent('play')

    else:
        raise RuntimeError("Argument not yet implemented")
Esempio n. 3
0
def command_line_parser():
    """Entry function"""
    print(__doc__)
    args = docopt(__doc__)
    if args['--log']:
        logfile = args['--log']
    else:
        print("Using default log file")
        logfile = 'default'
    model_name = args['--name'] if args['--name'] else 'dqn1'
    screenloglevel = logging.INFO if not args['--screenloglevel'] else \
        getattr(logging, args['--screenloglevel'].upper())
    _ = get_config()
    init_logger(screenlevel=screenloglevel, filename=logfile)
    print(f"Screenloglevel: {screenloglevel}")
    log = logging.getLogger("")
    log.info("Initializing program")

    if args['selfplay']:
        num_episodes = 1 if not args['--episodes'] else int(args['--episodes'])
        runner = SelfPlay(render=args['--render'], num_episodes=num_episodes, use_nn_equity=args['--use_nn_equity'],
                          use_cpp_montecarlo=args['--use_cpp_montecarlo'],
                          funds_plot=args['--funds_plot'],
                          stack=int(args['--stack']))

        if args['random']:
            runner.random_agents()

        elif args['keypress']:
            runner.key_press_agents()

        elif args['consider_equity']:
            runner.equity_vs_random()

        elif args['equity_improvement']:
            improvement_rounds = int(args['--improvement_rounds'])
            runner.equity_self_improvement(improvement_rounds)

        elif args['dqn_train']:
            runner.dqn_train_keras_rl(model_name)

        elif args['dqn_train_heads_up']:
            runner.dqn_train_heads_up_keras_rl(model_name)

        elif args['dqn_play']:
            runner.dqn_play_keras_rl(model_name)


    else:
        raise RuntimeError("Argument not yet implemented")