首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenAI健身房中的spaces.Discrete是什么意思

OpenAI健身房中的spaces.Discrete是什么意思
EN

Stack Overflow用户
提问于 2019-08-21 09:01:42
回答 1查看 12.6K关注 0票数 5

我尝试用openAI健身房学习MC-蒙特卡罗方法在二十一点游戏中的应用。我不明白这几句话:

代码语言:javascript
复制
def __init__(self, natural=False):
    self.action_space = spaces.Discrete(2)
    self.observation_space = spaces.Tuple((
        spaces.Discrete(32),
        spaces.Discrete(11),
        spaces.Discrete(2)))
    self.seed()

来源:https://github.com/openai/gym/blob/master/gym/envs/toy_text/blackjack.py

EN

回答 1

Stack Overflow用户

发布于 2019-08-21 11:46:38

观察空间和动作空间已在注释here中定义

观察空间:

代码语言:javascript
复制
The observation of a 3-tuple of: the player's current sum,
the dealer's one showing card (1-10 where 1 is ace),
and whether or not the player holds a usable ace (0 or 1).

eg: (14, 9, False) means the current sum is 14, card shown is 9 and there is no usable ace(because ace can be used as 1 or 11)

动作空间:

代码语言:javascript
复制
The player can request additional cards (hit=1) until they decide to stop
(stick=0) or exceed 21 (bust).

当我们在环境中定义离散的动作/观察空间时,使用离散空间。所以spaces.Discrete(2)意味着我们有一个离散变量,它可以取两个可能的值之一。

在二十一点环境中,

代码语言:javascript
复制
self.action_space = spaces.Discrete(2)
# here spaces.Discrete(2) means that action can either be True or False.

self.observation_space = spaces.Tuple((
        spaces.Discrete(32),
        spaces.Discrete(11),
        spaces.Discrete(2)))
# here spaces.Discrete(32) corresponds to the 32 possible sum of card number possible
# here spaces.Discrete(11) corresponds to the 11 possible cards which can be dealed
# by the dealer: [1,2,3,4,5,6,7,8,9,10(king,queen,jack),11(ace if possible)]
# here spaces.Discrete(2) corresponds to the two possible uses of the ace: [True, False]
# True if it can be used as 11.
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57583185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档