openAi 让电脑自己玩游戏
2017-12-14 本文已影响25人
a十二_4765
安装openIAi 裤子
window
pip install gym
linux py2
pip install gym
linux py3
pip3 install gym
import gym
env =gym.make('CartPole-v0')
for i_episode in range(20):
observation =env.reset()
for t 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(t+1))
break