def extract_stable_baselines_data(env, filename):
    """
        Extract the total timesteps and average episodic return from the logging
        data specified to Stable Baselines PPO2.

        Parameters:
            env - The environment we're currently graphing.
            filename - The file containing data. Should be "seed_xxx.txt" such that the
                        xxx are integers

        Return:
            x - the total timesteps at each iteration
            y - average episodic return at each iteration
    """
    # x is timesteps so far, y is average episodic reward
    x, y = [], []

    # extract out x's and y's
    with open(filename, 'r') as f:
        for l in f:
            l = [e.strip() for e in l.split('|')]
            if 'ep_reward_mean' in l:
                y.append(float(l[2]))
            elif 'ep_rew_mean' in l:
                y.append(float(l[2]))
            if 'total_timesteps' in l:
                x.append(int(l[2]))
    return x, y
Extract the total timesteps and average episodic return from the logging
data specified to Stable Baselines PPO2.

Parameters:
env - The environment we're currently graphing.
filename - The file containing data. Should be "seed_xxx.txt" such that the
xxx are integers

Return:
x - the total timesteps at each iteration
y - average episodic return at each iteration
part4/make_graph.py