如果Negamax要最小化根节点而不是最大化,它的初始函数调用会是什么样子?

Negamax通常看起来像下面这样:

function negamax(node, depth, α, β, color) is    if depth = 0 or node is a terminal node then        return color × the heuristic value of node    childNodes := generateMoves(node)    childNodes := orderMoves(childNodes)    value := −∞    foreach child in childNodes do        value := max(value, −negamax(child, depth − 1, −β, −α, −color))        α := max(α, value)        if α ≥ β then            break (* cut-off *)    return value

如果是最大化玩家调用,初始调用是 negamax(rootNode, depth, −∞, +∞, 1)

我以最大化玩家调用的方式实现了Negamax,但每个rootNode都是最大化玩家的一个移动:

function negamaxHandler() is    bestValue := −∞    bestNode := null    childNodes := generateMoves(currentGameState)    foreach child in childNodes do        value := negamax(child, depth-1, ???, ???, ???)        if value > bestValue then            bestValue := value            bestNode := child    return bestNode

由于Negamax返回一个值,我反而想要一个棋盘状态(移动)。所以我手动进行Negamax的第一级,以便解析出最佳移动。但我应该用什么值来调用negamax呢?更明确地说,如果最大化玩家调用了negamaxHandlernegamaxHandler应该调用:

negamax(child, depth-1, −∞, +∞, 1)-negamax(child, depth-1, −∞, +∞, 1)negamax(child, depth-1, +∞, −∞, -1)-negamax(child, depth-1, +∞, −∞, -1)

还是别的什么?为了澄清:

  • 最大化玩家调用negamaxHandler
  • negamaxHandler中对negamax的每个顶级调用应该最小化

回答:

正确的函数调用最终是-negamax(child, depth-1, −∞, +∞, -1),尽管negamaxHandler函数需要进行修改:

function negamaxHandler(α, β, color) is    bestValue := −∞    bestNode := null    childNodes := generateMoves(currentGameState)    foreach child in childNodes do        value := -negamax(child, depth-1, -β, -α, -color)        if value > bestValue then            bestValue := value            bestNode := child        α := max(bestValue, α)        if α ≥ β then           break    return bestNode

negamaxHandler的调用方式为negamaxHandler(−∞, +∞, 1)

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注