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)
Asked By: Kebasita

||

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)
Answered By: Mo Nazemi
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.