# Path: humanrl/utils.py
# ACTION_MEANING = {
#     None: "NONE",
#     0: "NOOP",
#     1: "FIRE",
#     2: "UP",
#     3: "RIGHT",
#     4: "LEFT",
#     5: "DOWN",
#     6: "UPRIGHT",
#     7: "UPLEFT",
#     8: "DOWNRIGHT",
#     9: "DOWNLEFT",
#     10: "UPFIRE",
#     11: "RIGHTFIRE",
#     12: "LEFTFIRE",
#     13: "DOWNFIRE",
#     14: "UPRIGHTFIRE",
#     15: "UPLEFTFIRE",
#     16: "DOWNRIGHTFIRE",
#     17: "DOWNLEFTFIRE",
# }


import argparse
import gzip
import logging
import os
import os.path
import pickle
import time
import gym
import numpy as np
import log_coordinator
from multiprocessing.connection import Client
from humanrl.utils import ACTION_MEANING
logger.setLevel(logging.INFO)

parser = argparse.ArgumentParser(description="Run commands")
parser.add_argument(
    '-f',
    '--frames-dir',
    type=str,
    default="/tmp/pong/frames",
    help="Directory to read and write frames to")


class Episode(object):
    def __init__(self):
        self.frames = []
        self.info = {}
        self.version = 2
        self.path = None

    def __setstate__(self, state):
        """ This method controls backwards-compatibility for unpickling: it's called every
        time a Frame is unpickled, so we can handle class-format changes easily."""
        if 'version' not in state.keys():
            self.__dict__.update(version=1)
        if 'path' not in state.keys():
            self.__dict__.update(path=None)
        self.__dict__.update(state)


class Frame(object):
    REAL = "real"

# Path: humanrl/utils.py
# ACTION_MEANING = {
#     None: "NONE",
#     0: "NOOP",
#     1: "FIRE",
#     2: "UP",
#     3: "RIGHT",
#     4: "LEFT",
#     5: "DOWN",
#     6: "UPRIGHT",
#     7: "UPLEFT",
#     8: "DOWNRIGHT",
#     9: "DOWNLEFT",
#     10: "UPFIRE",
#     11: "RIGHTFIRE",
#     12: "LEFTFIRE",
#     13: "DOWNFIRE",
#     14: "UPRIGHTFIRE",
#     15: "UPLEFTFIRE",
#     16: "DOWNRIGHTFIRE",
#     17: "DOWNLEFTFIRE",
# }


# Path: humanrl/frame.py
import argparse
import gzip
import logging
import os
import os.path
import pickle
import time
import gym
import numpy as np
import log_coordinator
from multiprocessing.connection import Client
from humanrl.utils import ACTION_MEANING

logger.setLevel(logging.INFO)

parser = argparse.ArgumentParser(description="Run commands")
parser.add_argument(
    '-f',
    '--frames-dir',
    type=str,
    default="/tmp/pong/frames",
    help="Directory to read and write frames to")


class Episode(object):
    def __init__(self):
        self.frames = []
        self.info = {}
        self.version = 2
        self.path = None

    def __setstate__(self, state):
        """ This method controls backwards-compatibility for unpickling: it's called every
        time a Frame is unpickled, so we can handle class-format changes easily."""
        if 'version' not in state.keys():
            self.__dict__.update(version=1)
        if 'path' not in state.keys():
            self.__dict__.update(path=None)
        self.__dict__.update(state)


class Frame(object):
    REAL = "real"

    PROPOSED = "proposed"