Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 815 Bytes

Stay within borders.md

File metadata and controls

23 lines (17 loc) · 815 Bytes

Stay within borders

Defines the track border and gives high rewards if all 4 wheels stay on the track, which leaves it to the model to find the optimal path.

def reward_function(params):
    # Example of rewarding the agent to stay inside the two borders of the track
    
    # Read input parameters
    all_wheels_on_track = params['all_wheels_on_track']
    distance_from_center = params['distance_from_center']
    track_width = params['track_width']
    
    # Give a very low reward by default
    reward = 1e-3

    # Give a high reward if no wheels go off the track and
    # the agent is somewhere in between the track borders
    if all_wheels_on_track and (0.5*track_width - distance_from_center) >= 0.05:
        reward = 1.0

    # Always return a float value
    return float(reward)