gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 03:03:45 26 4
gpt4 key购买 nike

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是最大化玩家 Action 之一:
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在?为了更具声明性,如果最大化播放器称为 negamaxHandler , 应该 negamaxHandler称呼:
negamax(child, depth-1, −∞, +∞, 1)
-negamax(child, depth-1, −∞, +∞, 1)
negamax(child, depth-1, +∞, −∞, -1)
-negamax(child, depth-1, +∞, −∞, -1)

或者是其他东西?澄清:
  • 最大化玩家调用 negamaxHandler
  • 每个顶级调用 negamaxnegamaxHandler应该最小化
  • 最佳答案

    正确的函数调用最终是 -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) .

    关于artificial-intelligence - 如果 Negamax 的初始函数调用是最小化根节点而不是最大化,它会是什么样子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59438037/

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