I am getting to know OpenAI's GYM (0.25.1) using Python3.10 with gym's environment set to 'FrozenLake-v1
(code below).
According to the documentation, calling env.step()
should return a tuple containing 4 values (observation, reward, done, info). However, when running my code accordingly, I get a ValueError:
Problematic code:
observation, reward, done, info = env.step(new_action)
Error:
3 new_action = env.action_space.sample()
----> 5 observation, reward, done, info = env.step(new_action)
7 # here's a look at what we get back
8 print(f"observation: {observation}, reward: {reward}, done: {done}, info: {info}")
ValueError: too many values to unpack (expected 4)
Adding one more variable fixes the error:
a, b, c, d, e = env.step(new_action)
print(a, b, c, d, e)
Output:
5 0 True True {'prob': 1.0}
My interpretation:
5
should be observation0
is rewardprob: 1.0
is info- One of the
True
's is done
So what's the leftover boolean standing for?
Thank you for your help!
Complete code:
import gym
env = gym.make('FrozenLake-v1', new_step_api=True, render_mode='ansi') # build environment
current_obs = env.reset() # start new episode
for e in env.render():
print(e)
new_action = env.action_space.sample() # random action
observation, reward, done, info = env.step(new_action) # perform action, ValueError!
for e in env.render():
print(e)