def agent(): """Run the agent, connecting to a (remote) host started independently.""" agent_module, agent_name = FLAGS.agent.rsplit(".", 1) agent_cls = getattr(importlib.import_module(agent_module), agent_name) logging.info("Starting agent:") with remote_sc2_env.RemoteSC2Env( map_name=FLAGS.map, host=FLAGS.host, host_port=FLAGS.host_port, lan_port=FLAGS.lan_port, race=sc2_env.Race[FLAGS.agent_race], step_mul=FLAGS.step_mul, agent_interface_format=sc2_env.parse_agent_interface_format( feature_screen=FLAGS.feature_screen_size, feature_minimap=FLAGS.feature_minimap_size, rgb_screen=FLAGS.rgb_screen_size, rgb_minimap=FLAGS.rgb_minimap_size, action_space=FLAGS.action_space, use_feature_units=FLAGS.use_feature_units), visualize=FLAGS.render) as env: agents = [agent_cls()] logging.info("Connected, starting run_loop.") try: run_loop.run_loop(agents, env) except remote_sc2_env.RestartException: pass logging.info("Done.")
def run_ladder_game(): # Join ladder game with remote_sc2_env.RemoteSC2Env( host=FLAGS.LadderServer, host_port=FLAGS.GamePort, lan_port=FLAGS.StartPort + 2, #s2client-api and pysc2 have different opinions what "startport" means, race=RACE, step_mul=STEP_MUL, agent_interface_format=AGENT_INTERFACE_FORMAT, visualize=platform.system() == "Linux") as env: agents = [AGENT] logging.info("Connected, starting run_loop.") try: run_loop.run_loop(agents, env) except remote_sc2_env.RestartException: pass logging.info("Done.")
def run_ladder_game(): # Join ladder game print('host', FLAGS.LadderServer) print('host_port', FLAGS.GamePort) print('lan_port', FLAGS.StartPort) with remote_sc2_env.RemoteSC2Env( host=FLAGS.LadderServer, host_port=FLAGS.GamePort, lan_port=FLAGS.StartPort + 2, #s2client-api and pysc2 have different opinions what "startport" means, race=RACE, ## step_mul=STEP_MUL, agent_interface_format=AGENT_INTERFACE_FORMAT, visualize=False, # name=.., # replay_dir='{}\\data\\replays'.format(os.path.abspath(os.getcwd())), # replay_prefix='aiarena', ) as env: agents = [AGENT] logging.info("Connected, starting run_loop.") try: run_loop.run_loop(agents, env) except remote_sc2_env.RestartException: pass logging.info("Done.")