-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug Report] CarRacing module crashes when executed directly and no longer stops after closing the window #3082
Comments
Thanks, that's a good catch. I'd actually consider removing the whole functionality of running individual files, it seems to be a relic of the old versions of gym, and overall not a great pattern. |
@foxik Would you be able to make a PR to fix it? |
Additionally, the running application can be stopped not just by closing the window, but also by pressing the Escape key. Fixed openai#3082.
@pseudo-rnd-thoughts No problem, I just created it. The handling of |
Additionally, the running application can be stopped not just by closing the window, but also by pressing the Escape key. Fixed #3082.
Describe the bug
When running the
car_racing.py
module directly, it fails withThis is caused by the recent rendering changes, because
car_racing.py
is constructingCarRacing
instance directly ingym/gym/envs/box2d/car_racing.py
Line 798 in f4d668f
The problem could be fixed by adding
render_mode="human"
to theCarRacing
constructor.There is also a second problem, however. The main cycle is
Previously,
isopen
was set when the user closed the viewer, which is no longer the case withpygame
. However:isopen
is not set when closing the window -- the window cannot be closed, actuallyrender
is called twice -- once inside thestep
, and also manually in the cycleI am not sure how to handle this use case:
render
method one can useisopen
flag and return it, then becauserender
is called twice now (once instep
), in 50% of the cases this flag will be returned from therender
call instep
method and will be ignored (because it will not be handled by the above cycle)QUIT
event, then:env.isopen
is exported from all environments with a viewer?self.surface
isNone
)Previously there was a single
Viewer
class handling rendering of allclassic_control
andbox2d
environments, but right now thepygame
logis is instead replicated in all of them. Maybe we could have again someViewer
class to provide basic functionality, so that changes like "allowing the user to close the window" would be implemented on one place, not identically in many modules.The text was updated successfully, but these errors were encountered: