(self, physics)
return np.hstack((standing, reach_ball, fetch_ball))
Returns a reward to the agent.
Returns a reward to the agent.
Returns a reward to the agent .
def get_reward_factors(self, physics):
    """Returns a reward to the agent."""
    standing = super().get_reward_factors(physics)

    # Reward for bringing mouth close to ball.
    bite_radius = physics.named.model.site_size['upper_bite', 0]
    bite_margin = 2
    reach_ball = rewards.tolerance(physics.ball_to_mouth_distance(),
                                   bounds=(0, bite_radius),
                                   sigmoid='reciprocal',
                                   margin=bite_margin)
    reach_ball = (6*reach_ball + 1) / 7

    # Reward for bringing the ball close to the target.
    target_radius = physics.named.model.geom_size['target', 0]
    bring_margin = physics.named.model.geom_size['floor', 0]
    ball_near_target = rewards.tolerance(
        physics.ball_to_target_distance(),
        bounds=(0, target_radius),
        sigmoid='reciprocal',
        margin=bring_margin)
    fetch_ball = (ball_near_target + 1) / 2

    # Let go of the ball if it's been fetched.
    if physics.ball_to_target_distance() < 2*target_radius:
      reach_ball = 1

    return np.hstack((standing, reach_ball, fetch_ball))
def get_reward_factors ( self , physics ) : standing = super ( ) . get_reward_factors ( physics ) # Reward for bringing mouth close to ball. bite_radius = physics . named . model . site_size [ 'upper_bite' , 0 ] bite_margin = 2 reach_ball = rewards . tolerance ( physics . ball_to_mouth_distance ( ) , bounds = ( 0 , bite_radius ) , sigmoid = 'reciprocal' , margin = bite_margin ) reach_ball = ( 6 * reach_ball + 1 ) / 7 # Reward for bringing the ball close to the target. target_radius = physics . named . model . geom_size [ 'target' , 0 ] bring_margin = physics . named . model . geom_size [ 'floor' , 0 ] ball_near_target = rewards . tolerance ( physics . ball_to_target_distance ( ) , bounds = ( 0 , target_radius ) , sigmoid = 'reciprocal' , margin = bring_margin ) fetch_ball = ( ball_near_target + 1 ) / 2 # Let go of the ball if it's been fetched. if physics . ball_to_target_distance ( ) < 2 * target_radius : reach_ball = 1 return np . hstack ( ( standing , reach_ball , fetch_ball ) )