What does spaces.Discrete mean in OpenAI Gym

题意:在OpenAI Gym的上下文中,spaces.Discrete 是指什么

问题背景:

I try to learn MC- Monte Carlo Method applied in blackjack using openAI Gym. And I do not understand these lines:

我尝试使用OpenAI Gym学习蒙特卡洛方法(Monte Carlo Method,简称MC)在黑杰克(Blackjack)游戏中的应用。但我不理解这些代码行/概念/部分:

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()

Source from: https://github.com/openai/gym/blob/master/gym/envs/toy_text/blackjack.py

源码引用地址

问题解决:

The observation space and the action space has been defined in the comments here

这里的注释中已经定义了观察空间(observation space)和动作空间(action space)

Observation Space:        观察空间

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)

Action Space:        动作空间

The player can request additional cards (hit=1) until they decide to stop
(stick=0) or exceed 21 (bust).

Discrete spaces are used when we have a discrete action/observation space to be defined in the environment. So spaces.Discrete(2) means that we have a discrete variable which can take one of the two possible values.

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

In the Blackjack environment,        在 Blackjack 环境中

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.

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值