def reward_function(params):
    # Read input variable
    track_width = params['track_width']
    distance_from_center = params['distance_from_center']
    # Calculate the distance from each border
    distance_from_border = 0.5 * track_width - distance_from_center
    # Reward higher if the car stays inside the track borders
    if distance_from_border >= 0.05:
        reward = 1.0
    else:
        reward = 1e-3 # Low reward if too close to the border or goes off the track
    return reward