如何调整我的Minimax搜索树来处理没有基于任期的游戏?

我必须做一个项目,我们需要实现mancala棋盘游戏,然后还为它实现AI。

我们被告知,我们需要修改或更改一个极大极小树,以便能够与游戏一起工作,因为在游戏中,玩家可以连续多次翻转。

我已经实现了我的游戏逻辑和GUI,但是现在在我开始使用AI之前,我想试着弄清楚它背后的理论。 我在网上搜索了基于非回合的迷你最大树,我似乎找不到任何东西。 但是我看到很多人在谈论使用超级极小马卡拉。

现在我明白了正常极小极大树以及每个层次如何在最小节点和最大节点之间交替。 有了我现在需要的树,我会说: min > max > max > min > max如果第二个玩家有两个回合?

我们还需要能够指定Minimax树的给定层厚度。 我们还需要进行alpha beta修剪,但是稍后会发生,一旦我真的有一棵树。


据我了解,你的主要问题如下:你已经被告知如何在max / min进入循环的情况下使用minimax,现在你有一个游戏,有时一个玩家可以连续做多个动作。

我会向你解释基本上适用于任何游戏的一般方法,然后我将添加一些可以对于mancala完成不同的事情。

所以一般的方法

标准最低限额是这样的:

function minimax(node, depth, maximizingPlayer)
    if depth = 0 or node is a terminal node
        return the heuristic value of node
    if maximizingPlayer
        bestValue := -∞
        for each child of node
            val := minimax(child, depth - 1, FALSE)
            bestValue := max(bestValue, val)
        return bestValue
    else
        bestValue := +∞
        for each child of node
            val := minimax(child, depth - 1, TRUE)
            bestValue := min(bestValue, val)
        return bestValue

你用max / min初始化minimax调用,然后不断变化。 在你的情况下,你只需要添加一个小检查。

function minimax(node, depth, maximizingPlayer)
    if depth = 0 or node is a terminal node
        return the heuristic value of node
    if maximizingPlayer
        bestValue := -∞
        for each child of node
            # here is a small change
            if freeTurn(child):
               isMax := TRUE
            else:
               isMax := FALSE
            val := minimax(child, depth - 1, isMax)
            bestValue := max(bestValue, val)
        return bestValue
    else
        bestValue := +∞
        for each child of node
            # here is a small change
            if freeTurn(child):
               isMax := FALSE
            else:
               isMax := TRUE
            val := minimax(child, depth - 1, isMax)
            bestValue := min(bestValue, val)
        return bestValue

你的功能freeTurn在你目前的行动之后是否有空闲回合。 请注意,这个算法没有区别,无论您只能连续进行2次移动还是连续进行5次移动。

关于Mancala

有很多变种,但是游戏的分支因素很小(我知道的是<= 6)。 现在假设你有三个动作ABCD ,移动C可以让你再玩一次。 从C位置你可以移动C1C2 。 所以你可以把它们( C + C1C + C2 )结合起来,把它们当作一个动作(小记账应该记住这实际上是两步)。 所以现在你最终得到你最小的最大迭代,你没有4但是5次移动: ABC + C1C + C2D 。 实际上,对于具有更大分支因子的游戏,使用这种方法没有任何问题。


如果一方在一个转弯中可以有多个移动,那么必须有一些方法来检测。 当检测到对手的移动发生器产生一个只包含空移动的列表,即一个什么都不做的移动。 对手将被迫执行该动作(不做任何事),然后第一个玩家可以计算他的下一步动作。

链接地址: http://www.djcxy.com/p/56327.html

上一篇: How to adapt my Minimax search tree to deal with no term based game?

下一篇: Beating a minimax opponent