def step(self, action):
    state = self.state
    (x, x_dot, theta, theta_dot) = state
    force = (self.force_mag * action[0])
    costheta = math.cos(theta)
    sintheta = math.sin(theta)
    temp = ((force + (((self.polemass_length * theta_dot) * theta_dot) * sintheta)) / self.total_mass)
    thetaacc = (((self.gravity * sintheta) - (costheta * temp)) / (self.length * ((4.0 / 3.0) - (((self.masspole * costheta) * costheta) / self.total_mass))))
    xacc = (temp - (((self.polemass_length * thetaacc) * costheta) / self.total_mass))
    if (self.kinematics_integrator == 'euler'):
        x = (x + (self.tau * x_dot))
        x_dot = (x_dot + (self.tau * xacc))
        theta = (theta + (self.tau * theta_dot))
        theta_dot = (theta_dot + (self.tau * thetaacc))
    else:
        x_dot = (x_dot + (self.tau * xacc))
        x = (x + (self.tau * x_dot))
        theta_dot = (theta_dot + (self.tau * thetaacc))
        theta = (theta + (self.tau * theta_dot))
    self.state = (x, x_dot, theta, theta_dot)
    done = ((x < (- self.x_threshold)) or (x > self.x_threshold) or (theta < (- self.theta_threshold_radians)) or (theta > self.theta_threshold_radians))
    done = bool(done)
    self.steps_in_episode += 1
    if (not done):
        reward = 1.0
    elif (self.steps_beyond_done is None):
        self.steps_beyond_done = 0
        reward = 1.0
    else:
        if (self.steps_beyond_done == 0):
            logger.warn("You are calling 'step()' even though this environment has already returned done = True. You should always call 'reset()' once you receive 'done = True' -- any further steps are undefined behavior.")
        self.steps_beyond_done += 1
        reward = 0.0
    info = {}
    info['success'] = (self.steps_in_episode >= 195)
    return (np.array(self.state), reward, done, info)
def step(self, action):
    state = self.state
    (x, x_dot, theta, theta_dot) = state
    force = (self.force_mag * action[0])
    costheta = math.cos(theta)
    sintheta = math.sin(theta)
    temp = ((force + (((self.polemass_length * theta_dot) * theta_dot) * sintheta)) / self.total_mass)
    thetaacc = (((self.gravity * sintheta) - (costheta * temp)) / (self.length * ((4.0 / 3.0) - (((self.masspole * costheta) * costheta) / self.total_mass))))
    xacc = (temp - (((self.polemass_length * thetaacc) * costheta) / self.total_mass))
    if (self.kinematics_integrator == 'euler'):
        x = (x + (self.tau * x_dot))
        x_dot = (x_dot + (self.tau * xacc))
        theta = (theta + (self.tau * theta_dot))
        theta_dot = (theta_dot + (self.tau * thetaacc))
    else:
        x_dot = (x_dot + (self.tau * xacc))
        x = (x + (self.tau * x_dot))
        theta_dot = (theta_dot + (self.tau * thetaacc))
        theta = (theta + (self.tau * theta_dot))
    self.state = (x, x_dot, theta, theta_dot)
    done = ((x < (- self.x_threshold)) or (x > self.x_threshold) or (theta < (- self.theta_threshold_radians)) or (theta > self.theta_threshold_radians))
    done = bool(done)
    self.steps_in_episode += 1
    if (not done):
        reward = 1.0
    elif (self.steps_beyond_done is None):
        self.steps_beyond_done = 0
        reward = 1.0
    else:
        if (self.steps_beyond_done == 0):
            logger.warn("You are calling 'step()' even though this environment has already returned done = True. You should always call 'reset()' once you receive 'done = True' -- any further steps are undefined behavior.")
        self.steps_beyond_done += 1
        reward = 0.0
    info = {}
    info['success'] = (self.steps_in_episode >= 195)
    return (np.array(self.state), reward, done, info)