Kautenja / gym-super-mario-bros

An OpenAI Gym interface to Super Mario Bros. & Super Mario Bros. 2 (Lost Levels) on The NES
Other
678 stars 133 forks source link

Graphical Glitch After Call to reset #72

Closed EliasHasle closed 5 years ago

EliasHasle commented 5 years ago

Describe the bug

When rendering to the screen, usually everything is OK, but sometimes, in my experience after a lot of resets, but that could be a coincidence, the images will, for a while, not update properly. The creatures behave normally, and Mario seems to interact with the actual environment, but the background image and object image flickers between two of the first, one of them clipped. This is in level 1-1 running 'SuperMarioBros-v0' (frameskip 4), and rendering using env.render('human') on a COMPLEX_MOVEMENT environment.

Notice clipped objects and ground: image

Here, Mario is actually between the tubes, but looks like he is somewhere else without tubes: image

I don't mind that the visualization is wrong, and to be honest my current agent doesn't either, as it is blind. But if this bug also affects observations, then it matters to other agents.

Environment

EliasHasle commented 5 years ago

A similar test with retro reveals that it performs about 3.5 times better, both with and without rendering to screen. I almost decided to use that instead, but it turned out to not support multiple emulator instances per process. I am happy to see that the newest version of nes-py is so flexible with regards to this. I am considering having multiple environment instances in each thread too, e.g. to send batches of frames from independent games throughthe same neural network. I may end up using both nes-py and retro, actually, for different things (must take care to have compatible reward functions if rewards will be used). Good job! :-)

Kautenja commented 5 years ago

Yea I'm not sure quite yet what trickery gets retro up to such a high frame rate. I was able to squeak out another 100 FPS from nes-py just by rearranging the C++ code here and there, so it's likely that more free performance gains are hidden in the code. Will continue reading up on C++ and injecting optimizations where possible. It would be great to dethrone their emulator!