grantsrb / gym-snake Goto Github PK
View Code? Open in Web Editor NEWAn OpenAI gym environment made for RL
An OpenAI gym environment made for RL
This is what I get when I train it on DQN
Traceback (most recent call last):
File "C:\Users\mahes\anaconda3\lib\site-packages\gym\utils\closer.py", line 67, in close
closeable.close()
File "C:\Users\mahes\anaconda3\lib\site-packages\gym\core.py", line 188, in close
self.render(close=True)
File "C:\Users\mahes\Gym-Snake\gym_snake\envs\snake_extrahard_env.py", line 44, in render
self.viewer.imshow(self.last_obs)
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib_init_.py", line 1492, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib\axes_axes.py", line 5756, in imshow
im.set_data(X)
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib\image.py", line 723, in set_data
self._A = self._normalize_image_array(A)
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib\image.py", line 693, in _normalize_image_array
raise TypeError(f"Invalid shape {A.shape} for image data")
TypeError: Invalid shape (8,) for image data
Exception ignored in: <function Env.del at 0x000001E853F6D4C0>
Traceback (most recent call last):
File "C:\Users\mahes\anaconda3\lib\site-packages\gym\core.py", line 252, in del
File "C:\Users\mahes\anaconda3\lib\site-packages\gym\core.py", line 188, in close
File "C:\Users\mahes\Gym-Snake\gym_snake\envs\snake_extrahard_env.py", line 43, in render
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib\axes_base.py", line 1388, in clear
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib\axes_base.py", line 1271, in __clear
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib\axis.py", line 895, in clear
File "C:\Users\mahes\anaconda3\lib\site-packages\matplotlib\text.py", line 175, in _reset_visual_defaults
AttributeError: 'NoneType' object has no attribute '_val_or_rc'
Hello. I found this seemingly flexible and aesthetic implementation of snake, and I wanted to try it out as soon as I could before training any model.
So, using the following code, I try to render a game with random movements gained from env.action_space.sample()
, but what happens is only the first frame renders, and I get
<Figure size 576x396 with 0 Axes>
returned for every frame thereafter.
Other OpenAI gym
environments render correctly for me, so what am I doing wrong, or is this a bug?
My code:
import gym
import gym_snake
## Creating environment
env = gym.make('snake-v0')
obs = env.reset()
## Observing snake for now
obs = env.reset()
for _ in range(5): # run for 1000 steps
env.render() # Render latest instance of game
action = [env.action_space.sample()] # Random action
env.step(action) # Implement action
env.close()
It would be nice to be able to flatten the images to greyscale by averaging across the 3rd dimension in the observation array (i.e. reduce to a lower dimension), but currently the food colour becomes the same as the grid colour (85).
I tried changing this:
grid_object.FOOD_COLOR = [0,0,0] # Color of food units
But it seemed to have no effect?
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.