我正在尝试实现一个 Q 学习代理来学习在井字游戏中与随机代理对战的最佳策略。
我制定了一个我相信会奏效的计划。只有一个部分我无法理解。这是因为环境中有两个玩家。
现在,Q Learning 代理应该对当前状态s
采取行动,给定一些策略采取a
的行动,给定动作的连续状态s'
,以及从该连续状态收到的任何奖励,r
。
让我们把它放到一个元组中 (s, a, r, s')
现在通常一个代理会对它在给定动作中遇到的每个状态采取行动,并使用 Q 学习方程来更新前一个状态的值。
然而,由于 Tic Tac Toe 有两个玩家,我们可以将状态集分成两个。一组状态可以是学习代理开始采取行动的状态。另一组状态可以是对手开始行动的地方。
那么,我们是否需要将状态一分为二?或者学习代理是否需要更新游戏中访问的每个状态?
I feel as though it should probably be the latter, as this might affect updating Q Values for when the opponent wins the game.
Any help with this would be great, as there does not seem to be anything online that helps with my predicament.
在花时间仔细检查这段代码之前,请先阅读下面的粗体文本后的问题。如果您无法回答这个问题,我不想浪费您的时间。
好的。我在 Haskell 中创建了自己的数据类型。这是
data Dialogue= Choice String [(String, Dialogue)]
| Action String Event
-- deriving (Show)
Run Code Online (Sandbox Code Playgroud)
请注意注释掉的“导出(显示)”,这对于我下面的问题很重要。
我有一个名为对话的函数定义为
dialogue:: Game -> Dialogue -> IO Game
dialogue (Game n p ps) (Action s e) = do
putStrLn s
return (e (Game n p ps))
dialogue (Game n p ps) (Choice s xs) = do
putStrLn s
let ys = [ fst a | a <- xs ]
let i = [1..length ys]
putStrLn (enumerate 1 ys)
str <- getLine
if …
Run Code Online (Sandbox Code Playgroud)