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

    Initializes the cart and pole according to `swing_up`, and in both cases
    adds a small random initial velocity to break symmetry.

    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.

    Initializes the cart and pole according to `swing_up`, and in both cases
    adds a small random initial velocity to break symmetry.

    Args:
      physics: An instance of `Physics`.
    """
    nv = physics.model.nv
    if self._swing_up:
      physics.named.data.qpos['slider'] = .01*self.random.randn()
      physics.named.data.qpos['hinge_1'] = np.pi + .01*self.random.randn()
      physics.named.data.qpos[2:] = .1*self.random.randn(nv - 2)
    else:
      physics.named.data.qpos['slider'] = self.random.uniform(-.1, .1)
      physics.named.data.qpos[1:] = self.random.uniform(-.034, .034, nv - 1)
    physics.named.data.qvel[:] = 0.01 * self.random.randn(physics.model.nv)
    super().initialize_episode(physics)
def initialize_episode ( self , physics ) : nv = physics . model . nv if self . _swing_up : physics . named . data . qpos [ 'slider' ] = .01 * self . random . randn ( ) physics . named . data . qpos [ 'hinge_1' ] = np . pi + .01 * self . random . randn ( ) physics . named . data . qpos [ 2 : ] = .1 * self . random . randn ( nv - 2 ) else : physics . named . data . qpos [ 'slider' ] = self . random . uniform ( - .1 , .1 ) physics . named . data . qpos [ 1 : ] = self . random . uniform ( - .034 , .034 , nv - 1 ) physics . named . data . qvel [ : ] = 0.01 * self . random . randn ( physics . model . nv ) super ( ) . initialize_episode ( physics )