shakenes / vizdoomgym Goto Github PK
View Code? Open in Web Editor NEWOpenAI Gym wrapper for ViZDoom enviroments
License: MIT License
OpenAI Gym wrapper for ViZDoom enviroments
License: MIT License
Hi
My model has trained on the vizdoomgym environment, but how do you recommend we visualize gameplay results?
I've tried wrapping the environment in the monitor class, but this returns "Could not find video" as an error, as defined in show_video(). Same code works fine for OpenAI's default gyms.
Any help is appreciated!
def show_video():
mp4list = glob.glob('video/*.mp4')
if len(mp4list) > 0:
mp4 = mp4list[0]
video = io.open(mp4, 'r+b').read()
encoded = base64.b64encode(video)
ipythondisplay.display(HTML(data='''<video alt="test" autoplay
loop controls style="height: 400px;">
<source src="data:video/mp4;base64,{0}" type="video/mp4" />
</video>'''.format(encoded.decode('ascii'))))
else:
print("Could not find video")
def wrap_env(env):
env = Monitor(env, './video', force=True)
return env
environment = wrap_env(env)
done = False
observation = environment.reset()
new_observation = observation
prev_input = None
environment = wrap_env(env)
done = False
observation = environment.reset()
new_observation = observation
prev_input = None
with tf.compat.v1.Session() as sess:
init.run()
observation, stacked_frames = stack_frames(stacked_frames, observation, True)
while True:
#set input to network to be difference image
#print(observation.shape)
# feed the game screen and get the Q values for each action
actions = mainQ_outputs.eval(feed_dict={X:[observation], in_training_mode:False})
# get the action
action = np.argmax(actions, axis=-1)
actions_counter[str(action)] += 1
# select the action using epsilon greedy policy
action = epsilon_greedy(action, global_step)
environment.render()
new_observation, stacked_frames = stack_frames(stacked_frames, new_observation, False)
observation = new_observation
# now perform the action and move to the next state, next_obs, receive reward
new_observation, reward, done, _ = environment.step(action)
if done:
break
environment.close()
show_video()
Hi,
Not sure if this is maintained any longer, but attempting to run your VizDoomBasic in a online Colaboratory notebook following your tutorial yields the error "No registered env with id: VizdoomBasic-v0"
Could you please tell us how to install this on windows since we can only see instruction for linux but any for windows?
import gym
import vizdoomgym
env = gym.make("VizdoomBasic-v0")
env.reset()
env.render()
env.env.close()
Generates the error:
Exception ignored in: <bound method SimpleImageViewer.__del__ of <gym.envs.classic_control.rendering.SimpleImageViewer object at 0x7fa15f523a90>>
Traceback (most recent call last):
File "/home/colin/py3/lib/python3.6/site-packages/gym/envs/classic_control/rendering.py", line 359, in __del__
File "/home/colin/py3/lib/python3.6/site-packages/gym/envs/classic_control/rendering.py", line 355, in close
File "/home/colin/py3/lib/python3.6/site-packages/pyglet/window/xlib/__init__.py", line 480, in close
File "/home/colin/py3/lib/python3.6/site-packages/pyglet/gl/xlib.py", line 345, in destroy
File "/home/colin/py3/lib/python3.6/site-packages/pyglet/gl/base.py", line 334, in destroy
File "/home/colin/py3/lib/python3.6/site-packages/pyglet/gl/xlib.py", line 335, in detach
File "/home/colin/py3/lib/python3.6/site-packages/pyglet/gl/lib.py", line 97, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down
I noticed that in the step function the state is recorded before the action is taken.
Which means that the observation returned is one step old and doesn't correspond to the current state.
Easy enough to fix by simply putting self.state = self.game.get_state()
after reward = self.game.make_action(act)
.
the code is as follows:
import gym
import vizdoomgym
env = gym.make('VizdoomBasic-v0')
File ".../vizdoomgym/vizdoomgym/envs/vizdoomenv.py", line 3, in
import vizdoom.vizdoom as vzd
ModuleNotFoundError: No module named 'vizdoom'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.