alex-petrenko / sample-factory

High throughput synchronous and asynchronous reinforcement learning
https://samplefactory.dev
MIT License
773 stars 106 forks source link

NetHack: fix rendering, handle timeouts #294

Closed BartekCupial closed 4 months ago

BartekCupial commented 4 months ago

This PR itroduces two small changes to the NetHack example

Fix rendering

Not sure if this is the best way to do this, but I wanted to correctly handle rendering. There is an issue when using GymV21CompatibilityV0 from shimmy library. Precisely in reset() they call env.render() before env.reset() which throws an error in NLE.

To fix this I've added modified GymV21CompatibilityV0 wrapper which swaps the order of env.reset() and env.render().

Handle timeouts

NLE is compatible with gym==0.21 and it doesn't distinguish between termination and truncation. Normally GymV21CompatibilityV0 handles this, but it needs info["TimeLimit.truncated"] to do so. I made it work by adding a simple wrapper.

codecov-commenter commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 77.85%. Comparing base (23df343) to head (e1bf6d2). Report is 2 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #294 +/- ## ========================================== + Coverage 77.83% 77.85% +0.02% ========================================== Files 101 101 Lines 7773 7773 ========================================== + Hits 6050 6052 +2 + Misses 1723 1721 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.