def GymEnv(env_id: str) -> gym.Env: """ Function to apply wrappers for all regular Gym envs by Trainer class :param env: Environment Name :type env: string :returns: Gym Environment :rtype: object """ env = gym.make(env_id) return GymWrapper(TimeLimit(env))
def AtariEnv( env_id: str, wrapper_list: List = [ AtariPreprocessing, NoopReset, FireReset, AtariTimeLimit, FrameStack, ], ) -> gym.Env: """ Function to apply wrappers for all Atari envs by Trainer class :param env: Environment Name :type env: string :param wrapper_list: List of wrappers to use :type wrapper_list: list or tuple :returns: Gym Atari Environment :rtype: object """ env = gym.make(env_id) env = GymWrapper(env) if "NoFrameskip" in env_id: frameskip = 1 elif "Deterministic" in env_id: frameskip = 4 else: frameskip = (2, 5) for wrapper in wrapper_list: if wrapper is AtariPreprocessing: env = wrapper(env, frameskip) else: env = wrapper(env) return env
from mario.base.wrapper import MarioEnv from mario.adversarial.expert_env import MarioExpertEnv from genrl.environments import FrameStack, GymWrapper from mario.base.wrapper import MarioPreprocessing # from gym_super_mario_bros.actions import COMPLEX_MOVEMENT # from nes_py.wrappers import JoypadSpace env = MarioExpertEnv("../toadstool", file_num=1) # env = JoypadSpace(env, COMPLEX_MOVEMENT) env = GymWrapper(env) env = MarioPreprocessing(env) env = FrameStack(env) state = env.reset() for t in range(10000): action = env.action_space.sample() state, reward, done, info = env.step(action) if True: env.render() if done: state = env.reset()
def MarioEnv(env): env = GymWrapper(env) env = MarioPreprocessing(env) env = FrameStack(env) env = MarioWrapper(env) return env