Esempio n. 1
0
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)
Esempio n. 2
0
def train_army(agent, train_action):
    # select multi building and train
    count = U.get_unit_num(agent.obs, C._GATEWAY_TYPE_INDEX)
    pos = selectGateway(agent)
    camera_on_base = U.check_base_camera(agent.env.game_info, agent.obs)
    # print(camera_on_base)
    if pos and camera_on_base:
        agent.select(C._SELECT_POINT, C._GATEWAY_GROUP_INDEX,
                     [C._DBL_CLICK, pos])
        agent.safe_action(C._CONTROL_GROUP, C._GATEWAY_GROUP_INDEX,
                          [C._SET_GROUP, C._GATEWAY_GROUP_ID])

        agent.select(C._SELECT_POINT, C._GATEWAY_GROUP_INDEX, [C._CLICK, pos])
        # agent.safe_action(C._CONTROL_GROUP, C._GATEWAY_GROUP_INDEX, [C._APPEND_GROUP, C._GATEWAY_GROUP_ID])
    else:
        agent.select(C._CONTROL_GROUP, C._GATEWAY_GROUP_INDEX,
                     [C._RECALL_GROUP, C._GATEWAY_GROUP_ID])

    use_multi = True
    if use_multi:
        for _ in range(count):
            agent.safe_action(train_action, C._GATEWAY_GROUP_INDEX,
                              [C._NOT_QUEUED])
    else:
        agent.safe_action(train_action, C._GATEWAY_GROUP_INDEX,
                          [C._NOT_QUEUED])
Esempio n. 3
0
def train_worker_only(agent):
    camera_on_base = U.check_base_camera(agent.env.game_info, agent.obs)
    assert camera_on_base, 'not camera_on_base!'

    # 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)
Esempio n. 4
0
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)
Esempio n. 5
0
def mineral_worker_only(agent):
    camera_on_base = U.check_base_camera(agent.env.game_info, agent.obs)
    assert camera_on_base, 'not camera_on_base!'

    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
    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)