Skip to content

Instantly share code, notes, and snippets.

@ipsec
Created September 14, 2022 17:28
Show Gist options
  • Save ipsec/2b4047f4501cfc5d918e39afaf939948 to your computer and use it in GitHub Desktop.
Save ipsec/2b4047f4501cfc5d918e39afaf939948 to your computer and use it in GitHub Desktop.
LunarLander-v2 using image
import gym
import numpy as np
from gym.spaces import Box
class ValidateLunarLanderImageEnv(gym.Env):
def __init__(self):
self.env = gym.make('LunarLander-v2')
obs = self.reset()
self.observation_space = Box(
low=0,
high=255,
dtype=np.uint8,
shape=obs.shape)
self.action_space = self.env.action_space
def convert_obs(self, observation):
observation = np.atleast_3d(observation)
if observation.max().item() != 0.:
observation *= 255.0/observation.max()
return observation.astype(np.uint8)
def reset(self):
observation = self.env.reset()
return self.convert_obs(observation)
def step(self, action: int):
obs, reward, done, info = self.env.step(action)
obs = self.convert_obs(obs)
return obs, reward, done, info
def close(self):
self.env.close()
return self.close()
@noospheer
Copy link

Hi @ipsec ... my comment is unrelated to this file. I'm trying to get your solution to this stochastic muzero nan training problem which was closed on another repo. Can you please share your solution? Thank you very much
DHDev0/Stochastic-muzero#2 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment