atari_environment.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:tensorflow-rl 作者: steveKapturowski 项目源码 文件源码
def get_actions(game_or_env):
    if isinstance(game_or_env, str):
        env = gym.make(game_or_env)
    else:
        env = game_or_env

    if isinstance(env.action_space, Discrete):
        num_actions = env.action_space.n
    elif isinstance(env.action_space, Box):
        num_actions = np.prod(env.action_space.shape)
    else:
        raise Exception('Unsupported Action Space \'{}\''.format(
            type(env.action_space).__name__))

    indices = range(num_actions)
    if env.spec.id in ['Pong-v0', 'Breakout-v0']:
        # Gym currently specifies 6 actions for pong and breakout when only 3 are needed
        # TODO: patch the environments instead
        num_actions = 3
        indices = [1 ,2, 3]

    return num_actions, env.action_space, indices
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号