(self, physics)
return _upright_reward(physics) * reach_then_fetch
Returns a reward to the agent.
Returns a reward to the agent.
Returns a reward to the agent .
def get_reward(self, physics):
    """Returns a reward to the agent."""

    # Reward for moving close to the ball.
    arena_radius = physics.named.model.geom_size['floor', 0] * np.sqrt(2)
    workspace_radius = physics.named.model.site_size['workspace', 0]
    ball_radius = physics.named.model.geom_size['ball', 0]
    reach_reward = rewards.tolerance(
        physics.self_to_ball_distance(),
        bounds=(0, workspace_radius+ball_radius),
        sigmoid='linear',
        margin=arena_radius, value_at_margin=0)

    # Reward for bringing the ball to the target.
    target_radius = physics.named.model.site_size['target', 0]
    fetch_reward = rewards.tolerance(
        physics.ball_to_target_distance(),
        bounds=(0, target_radius),
        sigmoid='linear',
        margin=arena_radius, value_at_margin=0)

    reach_then_fetch = reach_reward * (0.5 + 0.5*fetch_reward)

    return _upright_reward(physics) * reach_then_fetch
def get_reward ( self , physics ) : # Reward for moving close to the ball. arena_radius = physics . named . model . geom_size [ 'floor' , 0 ] * np . sqrt ( 2 ) workspace_radius = physics . named . model . site_size [ 'workspace' , 0 ] ball_radius = physics . named . model . geom_size [ 'ball' , 0 ] reach_reward = rewards . tolerance ( physics . self_to_ball_distance ( ) , bounds = ( 0 , workspace_radius + ball_radius ) , sigmoid = 'linear' , margin = arena_radius , value_at_margin = 0 ) # Reward for bringing the ball to the target. target_radius = physics . named . model . site_size [ 'target' , 0 ] fetch_reward = rewards . tolerance ( physics . ball_to_target_distance ( ) , bounds = ( 0 , target_radius ) , sigmoid = 'linear' , margin = arena_radius , value_at_margin = 0 ) reach_then_fetch = reach_reward * ( 0.5 + 0.5 * fetch_reward ) return _upright_reward ( physics ) * reach_then_fetch