# Path: humanrl/frame.py
# class Episode(object):
# class Frame(object):
# class HumanLabelWrapper(gym.Wrapper):
# class FrameSaverWrapper(gym.Wrapper):
#     def __init__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  observation=None,
#                  action=None,
#                  reward=None,
#                  image=None,
#                  info=None,
#                  label=None,
#                  prediction=None):
#     def has_action(self):
#     def get_label(self):
#     def set_label(self, label):
#     def was_blocked(self):
#     def get_proposed_action(self):
#     def get_real_action(self):
#     def get_action(self, action_type):
#     def set_proposed_action(self, action):
#     def set_real_action(self, action):
#     def __repr__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  env_id,
#                  env,
#                  online_blocking_mode="action_replacement",
#                  reward_scale=1.0,
#                  catastrophe_reward=0.0,
#                  **_):
#     def _reset(self):
#     def __send_init_msg(self):
#     def __send_frame_to_human(self, frame, proposed_action):
#     def __handle_feedback(self, msg, proposed_action):
#     def _step(self, proposed_action):
#     def _close(self):
#     def __init__(self, env, directory, max_episodes=1000):
#     def _reset(self):
#     def _step(self, action):
# def get_episode_number(filename):
# def paths_with_suffix(directory, empty_ok=False, suffixes=("pkl.gz", )):
# def episode_paths(directory, empty_ok=False):
# def feature_file_paths(directory, empty_ok=False):
# def load_episode(episode_path):
# def save_episode(episode_path, episode):
# def check_episode(episode_path):
# def fix_episode(episode_path):
#     REAL = "real"
#     PROPOSED = "proposed"


import gym
import numpy as np
from humanrl import frame
    from IPython import get_ipython  # isort:ignore
    from matplotlib import pyplot as plt  # isort:ignore
        lives = info.get("ale.lives", None)
        if lives is not None and lives < 3:
            done = True
        return obs, reward, done, info


class SpaceInvadersMonitoringWrapper(gym.Wrapper):
    def __init__(self, env):
        super().__init__(env)
        self.last_obs = None

    def _reset(self):
        obs = self.env.reset()
        self.last_obs = obs
        return obs

    def _step(self, action):
        obs, reward, done, info = self.env.step(action)
        if should_block(self.last_obs, action):
            info["frame/should_have_blocked"] = True
        self.last_obs = obs
        return obs, reward, done, info


if __name__ == "__main__":

    ipython = get_ipython()
    ipython.magic("matplotlib inline")

    eps = frame.episode_paths("logs/SpaceInvadersRandom")

# Path: humanrl/frame.py
# class Episode(object):
# class Frame(object):
# class HumanLabelWrapper(gym.Wrapper):
# class FrameSaverWrapper(gym.Wrapper):
#     def __init__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  observation=None,
#                  action=None,
#                  reward=None,
#                  image=None,
#                  info=None,
#                  label=None,
#                  prediction=None):
#     def has_action(self):
#     def get_label(self):
#     def set_label(self, label):
#     def was_blocked(self):
#     def get_proposed_action(self):
#     def get_real_action(self):
#     def get_action(self, action_type):
#     def set_proposed_action(self, action):
#     def set_real_action(self, action):
#     def __repr__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  env_id,
#                  env,
#                  online_blocking_mode="action_replacement",
#                  reward_scale=1.0,
#                  catastrophe_reward=0.0,
#                  **_):
#     def _reset(self):
#     def __send_init_msg(self):
#     def __send_frame_to_human(self, frame, proposed_action):
#     def __handle_feedback(self, msg, proposed_action):
#     def _step(self, proposed_action):
#     def _close(self):
#     def __init__(self, env, directory, max_episodes=1000):
#     def _reset(self):
#     def _step(self, action):
# def get_episode_number(filename):
# def paths_with_suffix(directory, empty_ok=False, suffixes=("pkl.gz", )):
# def episode_paths(directory, empty_ok=False):
# def feature_file_paths(directory, empty_ok=False):
# def load_episode(episode_path):
# def save_episode(episode_path, episode):
# def check_episode(episode_path):
# def fix_episode(episode_path):
#     REAL = "real"
#     PROPOSED = "proposed"


# Path: humanrl/space_invaders.py
import gym
import numpy as np
from humanrl import frame
    from IPython import get_ipython  # isort:ignore
    from matplotlib import pyplot as plt  # isort:ignore

        lives = info.get("ale.lives", None)
        if lives is not None and lives < 3:
            done = True
        return obs, reward, done, info


class SpaceInvadersMonitoringWrapper(gym.Wrapper):
    def __init__(self, env):
        super().__init__(env)
        self.last_obs = None

    def _reset(self):
        obs = self.env.reset()
        self.last_obs = obs
        return obs

    def _step(self, action):
        obs, reward, done, info = self.env.step(action)
        if should_block(self.last_obs, action):
            info["frame/should_have_blocked"] = True
        self.last_obs = obs
        return obs, reward, done, info


if __name__ == "__main__":

    ipython = get_ipython()
    ipython.magic("matplotlib inline")

    eps = frame.episode_paths("logs/SpaceInvadersRandom")

    ep = frame.load_episode(eps[0])