# Path: oscar/env/envs/pysc2_env.py
# class Pysc2Env(gym.Env):
#     """
#         abstract class for building pysc2 env for Gym
#     """
#     metadata = {'render.modes': ['human']}
# 
#     # must be defined by sub class !
#     pysc2_env = None
# 
#     last_obs = None
# 
#     def __init__(self):
#         pass
# 
#     def step(self, action):
#         """
#         move the environment forward of one step
#         :param action: a pysc2 action (a list of one pysc2 function call)
#         :return: tuple of pysc2 full observation structure, the reward for the step, if is the last
#             step or not and a dict to debug information (empty)
#         """
#         # Pysc2 can take a list of action :
#         # ( https://github.com/deepmind/pysc2/blob/7a04e74effc88d3e2fe0e4562c99a18d06a099b2/pysc2/env/sc2_env.py#L247 )
#         self.last_obs = self.pysc2_env.step(action)[0]
#         done = self.last_obs.step_type == environment.StepType.LAST
#         return self.last_obs, self.last_obs.reward, done, {}
# 
#     def reset(self):
#         self.last_obs = self.pysc2_env.reset()[0]
#         return self.last_obs
# 
#     def render(self, mode='human', close=False):
#         pass
# 
#     def close(self):
#         self.pysc2_env.close()
# 
#     def seed(self, seed=None):
#         # any way to set the seed of pysc2 ?
#         pass
# 
#     def get_action_mask(self):
#         pass


from pysc2.env.sc2_env import SC2Env
from pysc2.lib import actions
from pysc2.lib import features
from gym import spaces
from oscar.env.envs.pysc2_env import Pysc2Env
import numpy as np
import copy


"""API Constants"""
_PLAYER_RELATIVE = features.SCREEN_FEATURES.player_relative.index
_PLAYER_FRIENDLY = 1
_PLAYER_NEUTRAL = 3  # beacon/minerals
_PLAYER_HOSTILE = 4
_NO_OP = actions.FUNCTIONS.no_op.id
_MOVE_SCREEN = actions.FUNCTIONS.Move_screen.id
_ATTACK_SCREEN = actions.FUNCTIONS.Attack_screen.id
_SELECT_ARMY = actions.FUNCTIONS.select_army.id
_SELECT_POINT = actions.FUNCTIONS.select_point.id
_SELECT_RECT = actions.FUNCTIONS.select_rect.id
_NOT_QUEUED = [0]
_SELECT_ALL = [0]
_ADD_TO_SELECTION = [1]
_NEW_SELECTION = [0]

OBS_LENGTH = 4



# Path: oscar/env/envs/pysc2_env.py
# class Pysc2Env(gym.Env):
#     """
#         abstract class for building pysc2 env for Gym
#     """
#     metadata = {'render.modes': ['human']}
# 
#     # must be defined by sub class !
#     pysc2_env = None
# 
#     last_obs = None
# 
#     def __init__(self):
#         pass
# 
#     def step(self, action):
#         """
#         move the environment forward of one step
#         :param action: a pysc2 action (a list of one pysc2 function call)
#         :return: tuple of pysc2 full observation structure, the reward for the step, if is the last
#             step or not and a dict to debug information (empty)
#         """
#         # Pysc2 can take a list of action :
#         # ( https://github.com/deepmind/pysc2/blob/7a04e74effc88d3e2fe0e4562c99a18d06a099b2/pysc2/env/sc2_env.py#L247 )
#         self.last_obs = self.pysc2_env.step(action)[0]
#         done = self.last_obs.step_type == environment.StepType.LAST
#         return self.last_obs, self.last_obs.reward, done, {}
# 
#     def reset(self):
#         self.last_obs = self.pysc2_env.reset()[0]
#         return self.last_obs
# 
#     def render(self, mode='human', close=False):
#         pass
# 
#     def close(self):
#         self.pysc2_env.close()
# 
#     def seed(self, seed=None):
#         # any way to set the seed of pysc2 ?
#         pass
# 
#     def get_action_mask(self):
#         pass


# Path: oscar/env/envs/pysc2_mineralshard_env2.py
from pysc2.env.sc2_env import SC2Env
from pysc2.lib import actions
from pysc2.lib import features
from gym import spaces
from oscar.env.envs.pysc2_env import Pysc2Env
import numpy as np
import copy



"""API Constants"""
_PLAYER_RELATIVE = features.SCREEN_FEATURES.player_relative.index
_PLAYER_FRIENDLY = 1
_PLAYER_NEUTRAL = 3  # beacon/minerals
_PLAYER_HOSTILE = 4
_NO_OP = actions.FUNCTIONS.no_op.id
_MOVE_SCREEN = actions.FUNCTIONS.Move_screen.id
_ATTACK_SCREEN = actions.FUNCTIONS.Attack_screen.id
_SELECT_ARMY = actions.FUNCTIONS.select_army.id
_SELECT_POINT = actions.FUNCTIONS.select_point.id
_SELECT_RECT = actions.FUNCTIONS.select_rect.id
_NOT_QUEUED = [0]
_SELECT_ALL = [0]
_ADD_TO_SELECTION = [1]
_NEW_SELECTION = [0]

OBS_LENGTH = 4



class Pysc2MineralshardEnv2(Pysc2Env):