# 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.info('Opening connection...')
        # open connection on 6666 (won't support multiple workers)
        address = ('localhost', 6666)
        self.conn = Client(address, authkey=b'no-catastrophes-allowed')
        time.sleep(2.0)

    def _reset(self):
        self.__send_init_msg()
        observation = self.env.reset()
        # note - when run with FrameSaverWrapper, render happens twice (not sure if cached)
        image = self.env.render("rgb_array")
        self.current_frame = Frame(observation, None, 0, image, {})
        return observation

    def __send_init_msg(self):
        logger.info('Sending initial message...')
        init_msg_dict = {
            'msg': 'init'
        }  # todo - don't get episode num in human_feedback.py from this dict
        init_msg_dict.update(self.episode_info_common)
        init_msg_dict['env_id'] = self.env_id
        self.conn.send(init_msg_dict)

    def __send_frame_to_human(self, frame, proposed_action):
        """ Sends a frame with a proposed action to the human for feedback. """
        # if proposed_action is not None and frame.action is not None:
        frame.action = proposed_action
        frame.info["frame/action/proposed_action"] = proposed_action
        # info["frame/action/real_action"] = real_action


# 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.info('Opening connection...')
        # open connection on 6666 (won't support multiple workers)
        address = ('localhost', 6666)
        self.conn = Client(address, authkey=b'no-catastrophes-allowed')
        time.sleep(2.0)

    def _reset(self):
        self.__send_init_msg()
        observation = self.env.reset()
        # note - when run with FrameSaverWrapper, render happens twice (not sure if cached)
        image = self.env.render("rgb_array")
        self.current_frame = Frame(observation, None, 0, image, {})
        return observation

    def __send_init_msg(self):
        logger.info('Sending initial message...')
        init_msg_dict = {
            'msg': 'init'
        }  # todo - don't get episode num in human_feedback.py from this dict
        init_msg_dict.update(self.episode_info_common)
        init_msg_dict['env_id'] = self.env_id
        self.conn.send(init_msg_dict)

    def __send_frame_to_human(self, frame, proposed_action):
        """ Sends a frame with a proposed action to the human for feedback. """
        # if proposed_action is not None and frame.action is not None:
        frame.action = proposed_action
        frame.info["frame/action/proposed_action"] = proposed_action
        # info["frame/action/real_action"] = real_action


        proposed_action_meaning = ACTION_MEANING[self.episode_info_common["action_set"][