win10 安装openai和gym[atari]

1.OpenAI的安装

首先先在annnacoda下的envs文件夹中新建一个名为gym的文件夹,这点很重要!!!
在cmd中运行下面行代码

conda install --name gym python=3.5
activate gym
pip install gym -i  https://pypi.tuna.tsinghua.edu.cn/simple

等待下载安装完后
在命令行输入python
输入下面代码进行测试:

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

会出现一个摆锤一样的图片就是成功了

2. win10下安装openai gym[atari]

运行 pip install --no-index -f https://github.com/Kojoley/atari-py/releases atari_py
装完后测试

import gym
env = gym.make('Pong-v0')
 
for i_episode in range(100):
    env.reset()
    for t in range(100):
        env.render()
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode finished after {} timesteps".format(t+1))
            break

你可能感兴趣的:(其他)