gpt4 book ai didi

python-3.x - OpenAI Gym 中的 Spaces.Discrete 是什么意思

转载 作者:行者123 更新时间:2023-12-03 22:05:20 28 4
gpt4 key购买 nike

我尝试使用 openAI Gym 学习在二十一点中应用的 MC-蒙特卡罗方法。我不明白这些行:

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

最佳答案

观察空间和 Action 空间已经在评论 here 中定义

观察空间:

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 空间:
The player can request additional cards (hit=1) until they decide to stop
(stick=0) or exceed 21 (bust).

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

在 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.

关于python-3.x - OpenAI Gym 中的 Spaces.Discrete 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57583185/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com