阅读(4353)
赞(0)
AI人工智能 用Python构建一个学习代理
2020-09-24 11:07:56 更新
对于构建强化学习代理,我们将使用如下所示的 OpenAI Gym 包 -
import gym
env = gym.make('CartPole-v0')
for _ in range(20):
observation = env.reset()
for i in range(100):
env.render()
print(observation)
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
if done:
print("Episode finished after {} timesteps".format(i+1))
break
观察小推车可以平衡。