def mineral_worker(agent): camera_on_base = U.check_base_camera(agent.env.game_info, agent.obs) # print(camera_on_base) if not camera_on_base: return gas_pos = U.judge_gas_worker(agent.obs, agent.env.game_info) if gas_pos: probe = U.get_mineral_probe(agent.obs) probe_pos = T.world_to_screen_pos(agent.env.game_info, probe.pos, agent.obs) if probe else None move_worker(agent, gas_pos, probe_pos) if U.judge_gas_worker_too_many(agent.obs): probe = U.get_gas_probe(agent.obs) probe_pos = T.world_to_screen_pos(agent.env.game_info, probe.pos, agent.obs) if probe else None # print('probe_pos', probe_pos) mineral = U.find_unit_on_screen(agent.obs, C._MINERAL_TYPE_INDEX) mineral_pos = T.world_to_screen_pos(agent.env.game_info, mineral.pos, agent.obs) if mineral else None move_worker(agent, mineral_pos, probe_pos) # move_worker(agent, C.mineral_pos, probe_pos) else: # train_worker(agent, C.base_pos, C._TRAIN_PROBE) base = U.find_unit_on_screen(agent.obs, C._NEXUS_TYPE_INDEX) base_pos = T.world_to_screen_pos(agent.env.game_info, base.pos, agent.obs) if base else None train_worker(agent, base_pos, C._TRAIN_PROBE)
def gas_worker_only(agent): camera_on_base = U.check_base_camera(agent.env.game_info, agent.obs) assert camera_on_base, 'not camera_on_base!' gas_pos = U.judge_gas_worker(agent.obs, agent.env.game_info) if gas_pos: probe = U.get_mineral_probe(agent.obs) probe_pos = T.world_to_screen_pos(agent.env.game_info, probe.pos, agent.obs) if probe else None move_worker(agent, gas_pos, probe_pos)