(self, physics)
Sets the state of the environment at the start of each episode.

    Args:
      physics: An instance of `Physics`.
Sets the state of the environment at the start of each episode.
Sets the state of the environment at the start of each episode .
def initialize_episode(self, physics):
    """Sets the state of the environment at the start of each episode.

    Args:
      physics: An instance of `Physics`.

    """
    # Initial configuration, random azimuth and horizontal position.
    azimuth = self.random.uniform(0, 2*np.pi)
    orientation = np.array((np.cos(azimuth/2), 0, 0, np.sin(azimuth/2)))
    spawn_radius = 0.9 * physics.named.model.geom_size['floor', 0]
    x_pos, y_pos = self.random.uniform(-spawn_radius, spawn_radius, size=(2,))
    _find_non_contacting_height(physics, orientation, x_pos, y_pos)

    # Initial ball state.
    physics.named.data.qpos['ball_root'][:2] = self.random.uniform(
        -spawn_radius, spawn_radius, size=(2,))
    physics.named.data.qpos['ball_root'][2] = 2
    physics.named.data.qvel['ball_root'][:2] = 5*self.random.randn(2)
    super().initialize_episode(physics)
def initialize_episode ( self , physics ) : # Initial configuration, random azimuth and horizontal position. azimuth = self . random . uniform ( 0 , 2 * np . pi ) orientation = np . array ( ( np . cos ( azimuth / 2 ) , 0 , 0 , np . sin ( azimuth / 2 ) ) ) spawn_radius = 0.9 * physics . named . model . geom_size [ 'floor' , 0 ] x_pos , y_pos = self . random . uniform ( - spawn_radius , spawn_radius , size = ( 2 , ) ) _find_non_contacting_height ( physics , orientation , x_pos , y_pos ) # Initial ball state. physics . named . data . qpos [ 'ball_root' ] [ : 2 ] = self . random . uniform ( - spawn_radius , spawn_radius , size = ( 2 , ) ) physics . named . data . qpos [ 'ball_root' ] [ 2 ] = 2 physics . named . data . qvel [ 'ball_root' ] [ : 2 ] = 5 * self . random . randn ( 2 ) super ( ) . initialize_episode ( physics )