openai Gym env.P,AttributeError“ TimeLimit”对象没有属性“ P”

giu*_*iov 2 python reinforcement-learning python-3.x openai-gym

我目前正在阅读Sudharsan Ravichandiran撰写的Python动手强化学习,在第一个例子中,我遇到了这个AttributeError:

AttributeError 'TimeLimit' object has no attribute 'P'

由以下行引发:

for next_sr in env.P[state][action]: 
Run Code Online (Sandbox Code Playgroud)

我找不到有关env.P的任何文档,但在这里找到了用python2编写的类似示例:https : //gym.openai.com/evaluations/eval_48sirBRSRAapMjotYzjb6w/

我想env.P是一个过时的库的一部分(即使这本书于2018年6月出版,并且隐含的代码在python3中),那么我该如何替换呢?

小智 8

尝试先通过添加以下内容来解开环境

env = env.unwrapped