Cartpole problem: Too many values to unpack (expected 4)
Question:
The code for the classic reinforcement learning Cartpole problem throws up an error:
ValueError: too many values to unpack (expected 4)
when the following code is used:
# Take action and observe next state and reward
next_state, reward, done, info = env.step(action)
Answers:
I assume you are using gymnasium.
env.step returns five values, not four. https://gymnasium.farama.org/api/env/#gymnasium.Env.step
next_state, reward, truncated, terminated, info = env.step(action)
The code for the classic reinforcement learning Cartpole problem throws up an error:
ValueError: too many values to unpack (expected 4)
when the following code is used:
# Take action and observe next state and reward
next_state, reward, done, info = env.step(action)
I assume you are using gymnasium.
env.step returns five values, not four. https://gymnasium.farama.org/api/env/#gymnasium.Env.step
next_state, reward, truncated, terminated, info = env.step(action)