def isFinished(self):
        # Criterion for ending an episode.
        # When the agent reaches the goal, the task is considered learned.
        # When the agent falls down, the episode is over.

        if np.abs(self.env.getTilt()) > self.max_tilt:
            return True

        dist_to_goal = self.calc_dist_to_goal()
        if dist_to_goal == 0:
            print 'reached goal'
            return True

        elapsed_time = self.env.time_step * self.t
        if elapsed_time > self.max_time or dist_to_goal > self.env.max_distance:
            print 'time elapsed', self.t, elapsed_time
            print 'distance to goal', dist_to_goal
            return True    
        return False
dataset/ETHPy150Open chrisdembia/agent-bicycle/randlov1998/tasks.py/LSPIGotoTask.isFinished/original