pythonpython-3.xreinforcement-learningopenai-gym

openai gym env.P, AttributeError 'TimeLimit' object has no attribute 'P'


I'm currently reading Hands-On Reinforcement Learning with Python by Sudharsan Ravichandiran and on one of the first examples I run into this AttributeError:

AttributeError 'TimeLimit' object has no attribute 'P'

raised by the following line:

for next_sr in env.P[state][action]: 

I can't find any documentation regarding env.P, but I found a similar example written in python2 here: https://gym.openai.com/evaluations/eval_48sirBRSRAapMjotYzjb6w/

I suppose env.P is part of an outdated library (even if the the book was published on June 2018 and the incriminated code is in python3), so how can i replace it?


Solution

  • Try to unwrap the env first by adding this

    env = env.unwrapped