예제 #1
0
def next_move(hunter_position,
              hunter_heading,
              target_measurement,
              max_distance,
              OTHER=None):
    # This function will be called after each time the target moves.

    turning = 0
    distance = 0
    N = 4  # Count until hunter locks current heading (target) pos. Adjust as needed
    d = distance_between(hunter_position, target_measurement)

    tbot_next_xy, OTHER = estimate_next_pos(target_measurement, OTHER)

    if len(OTHER) < 6:
        OTHER.append([0, []])  # [lock_count,[lock_pos]]
        hunter_d = distance_between(tbot_next_xy, hunter_position)
        turning = get_bearing(tbot_next_xy, hunter_position, hunter_heading)
        distance = max_distance
    else:
        if OTHER[5][
                0] > 0:  # caveat, update the same lock target as per current traxbot pos
            OTHER[5][0] -= 1
            N = OTHER[5][0]
        else:  # Lock a target (N steps ahead of traxbot's current pos)
            OTHER[5][0] = N

        # Calculate hunter's next lock pos. (where it needs to head for the next lock_count, N)
        temp = deepcopy(OTHER)
        tbot_sim_xy = tbot_next_xy

        # Simulate traxbot moves
        for i in range(N):  # Adjust this as required
            tbot_sim_xy, temp = estimate_next_pos(tbot_sim_xy, temp)

        hunter_d = distance_between(tbot_sim_xy, hunter_position)
        turning = get_bearing(tbot_sim_xy, hunter_position, hunter_heading)
        distance = min(hunter_d, max_distance)

    if hunter_d < 2:
        print '%s : %s' % (
            str(hunter_d),
            str(distance_between(target_measurement, hunter_position)))

    # The OTHER variable is a place for you to store any historical information about
    # the progress of the hunt (or maybe some localization information). Your return format
    # must be as follows in order to be graded properly.
    return turning, distance, OTHER
def next_move(hunter_position, hunter_heading, target_measurement, max_distance, OTHER = None):
    # This function will be called after each time the target moves. 

    turning = 0
    distance = 0
    N = 4       # Count until hunter locks current heading (target) pos. Adjust as needed
    d = distance_between(hunter_position, target_measurement)

    tbot_next_xy, OTHER = estimate_next_pos(target_measurement, OTHER)
    
    
    if len(OTHER) < 6:
        OTHER.append([0,[]])     # [lock_count,[lock_pos]]
        hunter_d = distance_between(tbot_next_xy, hunter_position)
        turning = get_bearing(tbot_next_xy, hunter_position, hunter_heading)
        distance = max_distance
    else:
        if OTHER[5][0] > 0:       # caveat, update the same lock target as per current traxbot pos
            OTHER[5][0] -= 1
            N = OTHER[5][0]
        else:                   # Lock a target (N steps ahead of traxbot's current pos)
            OTHER[5][0] = N

        # Calculate hunter's next lock pos. (where it needs to head for the next lock_count, N)
        temp = deepcopy(OTHER)
        tbot_sim_xy = tbot_next_xy

        # Simulate traxbot moves
        for i in range(N):  # Adjust this as required
            tbot_sim_xy, temp = estimate_next_pos(tbot_sim_xy, temp)

        hunter_d = distance_between(tbot_sim_xy, hunter_position)
        turning = get_bearing(tbot_sim_xy, hunter_position, hunter_heading)
        distance = min(hunter_d, max_distance)

    if hunter_d < 2:
        print '%s : %s' % (str(hunter_d), str(distance_between(target_measurement, hunter_position)))

    # The OTHER variable is a place for you to store any historical information about
    # the progress of the hunt (or maybe some localization information). Your return format
    # must be as follows in order to be graded properly.
    return turning, distance, OTHER
def next_move(hunter_position, hunter_heading, target_measurement, max_distance, OTHER = None):
    # This function will be called after each time the target moves. 
    '''ALGO:
    - Predict TraxBot's next pos.
    - Calculate hunter's distance and bearing.
    - Turn by bearing and move by min(distance, max_distance)'''
    turning = 0
    distance = 0

    tbot_next_xy, OTHER = estimate_next_pos(target_measurement, OTHER)
    hunter_d = distance_between(tbot_next_xy, hunter_position)
    turning = get_bearing(tbot_next_xy, hunter_position, hunter_heading)
    distance = min(hunter_d, max_distance)

    # The OTHER variable is a place for you to store any historical information about
    # the progress of the hunt (or maybe some localization information). Your return format
    # must be as follows in order to be graded properly.
    return turning, distance, OTHER
def next_move(hunter_position,
              hunter_heading,
              target_measurement,
              max_distance,
              OTHER=None):
    # This function will be called after each time the target moves.
    '''ALGO:
    - Predict TraxBot's next pos.
    - Calculate hunter's distance and bearing.
    - Turn by bearing and move by min(distance, max_distance)'''
    turning = 0
    distance = 0

    tbot_next_xy, OTHER = estimate_next_pos(target_measurement, OTHER)
    hunter_d = distance_between(tbot_next_xy, hunter_position)
    turning = get_bearing(tbot_next_xy, hunter_position, hunter_heading)
    distance = min(hunter_d, max_distance)

    # The OTHER variable is a place for you to store any historical information about
    # the progress of the hunt (or maybe some localization information). Your return format
    # must be as follows in order to be graded properly.
    return turning, distance, OTHER