我正在尝试为益智游戏 baba is you 的 python 导入构建强化学习模型。 当我尝试使用 gym 创建环境并调用
action_space()
方法时,出现以下错误。
Exception has occurred: AssertionError
action space does not inherit from `gym.spaces.Space`, actual type: <class 'list'>
File "/Users/Shark/Projects/baba-is-auto/Extensions/BabaRL/baba-babaisyou-v0/REINFORCE.py", line 21, in <module>
env = gym.make('baba-babaisyou-v0')
AssertionError: action space does not inherit from `gym.spaces.Space`, actual type: <class 'list'>
这是我发生错误的代码位。
env = gym.make('baba-babaisyou-v0')
def get_action(state):
state = torch.tensor(state).to(device)
policy = net(state)
m = Categorical(policy)
action = m.sample()
net.log_probs.append(m.log_prob(action))
return env.action_space[action.item()]
我该如何解决这个错误?
我似乎找不到任何可靠的答案。