Gymnasium icon indicating copy to clipboard operation
Gymnasium copied to clipboard

[Proposal] Uniform API for Getting the Current State (and maybe setting it as well?) for Environments

Open Delta-Sigma opened this issue 10 months ago • 3 comments

Proposal

Uniform API for all environments for something like .get_state() and .set_state(state) or maybe .get_last_obs() or something like an Env instance attribute: Env.state

Motivation

All environments compute the state already and return it when you do reset or step. Getting the current state can be very neat e.g. when you want to have a wrapper to an environment that does something non-standard in some specific states e.g. only one tile in FrozenLake is slippery.

Sorry if this has been addressed already, I tried searching to the best of my ability whether this was already proposed or not.

And then, in the future, setting a state can also be very useful?

Pitch

No response

Alternatives

Alternatives that I can think of would not be so neat e.g. the wrapper is passed the last state every time some special needs to be taken, and user's code keeps track of last observation/state etc.

Another alternative would be that people needing such functionality modify the code of the environments themselves, which again I think is not so neat and requires needless diving into the internal workings of environments.

Additional context

No response

Checklist

  • [X] I have checked that there is no similar issue in the repo

Delta-Sigma avatar Apr 05 '24 11:04 Delta-Sigma

see https://github.com/Farama-Foundation/Gymnasium/issues/842, this will be worked on after 1.0 release

Kallinteris-Andreas avatar Apr 05 '24 18:04 Kallinteris-Andreas

Thank you for your reply.

Just to be clear I am also interested in getting the last/current observation, not just the state e.g. in cases when internal state and observations are not the same and/or do not contain the same information.

Looking forward to 1.0

EDIT: Sorry I closed and opened the issue by mistake. You'll be the better judge of whether to mark it as closed or not. Sorry about the unwanted notifications.

Delta-Sigma avatar Apr 05 '24 20:04 Delta-Sigma

Observation is already returned by step()

Kallinteris-Andreas avatar Apr 25 '24 07:04 Kallinteris-Andreas