示例#1
0
def turn(gc, unit):
    Units.shoot_at_best_target(gc, unit)
    if gc.is_move_ready(unit.id):
        planet = unit.location.map_location().planet
        path = get_closest_fact(unit) if planet == bc.Planet.Earth else Globals.updatePathMars
        Navigation.path_with_bfs(gc, unit, path)
    return
示例#2
0
def turn(gc, unit):
    # t = time.time()
    result = Units.shoot_at_best_target(gc, unit)
    # Globals.ranger_find_time += time.time() - t
    # print("find target time", Globals.ranger_find_time)
    if isinstance(result, bc.Unit):
        return
    elif isinstance(result, bc.VecUnit):
        nearby_enemies = result
    else:
        nearby_enemies = send_radar_info(unit, gc)
    # t = time.time()
    if gc.is_move_ready(unit.id):
        e, should_retreat = ranger_retreat(unit, nearby_enemies)
        if should_retreat:
            moved = Navigation.retreatFromKnownEnemy(gc, unit, Globals.radar.get_enemy_center(unit.location.map_location().planet))
            if moved:
                return
        if gc.is_attack_ready(unit.id):
            planet = unit.location.map_location().planet
            path = Globals.updatePath if planet == bc.Planet.Earth else Globals.updatePathMars
            Navigation.path_with_bfs(gc, unit, path)
    # Globals.ranger_else_time += time.time() - t
    # print("other ranger time", Globals.ranger_else_time)
    return