def step(self, a):
    posbefore = self.sim.data.qpos[0]
    self.do_simulation(a, self.frame_skip)
    (posafter, height, ang) = self.sim.data.qpos[0:3]
    alive_bonus = 1.0
    reward = ((posafter - posbefore) / self.dt)
    reward += alive_bonus
    reward -= (0.001 * np.square(a).sum())
    s = self.state_vector()
    done = (not (np.isfinite(s).all() and (np.abs(s[2:]) < 100).all() and (height > 0.7) and (abs(ang) < 0.2)))
    ob = self._get_obs()
    self.t += 1
    self.r += reward
    if done:
        return_r = self.r
        self.r = 0
        self.t = 0
    else:
        return_r = 0
    return (ob, return_r, done, {})
def step(self, a):
    posbefore = self.sim.data.qpos[0]
    self.do_simulation(a, self.frame_skip)
    (posafter, height, ang) = self.sim.data.qpos[0:3]
    alive_bonus = 1.0
    reward = ((posafter - posbefore) / self.dt)
    reward += alive_bonus
    reward -= (0.001 * np.square(a).sum())
    s = self.state_vector()
    done = (not (np.isfinite(s).all() and (np.abs(s[2:]) < 100).all() and (height > 0.7) and (abs(ang) < 0.2)))
    ob = self._get_obs()
    self.t += 1
    self.r += reward
    if done:
        return_r = self.r
        self.r = 0
        self.t = 0
    else:
        return_r = 0
    return (ob, return_r, done, {})